Troubleshooting Guide
This guide contains solutions for common issues encountered by developers and operators in the Tower Defense project.
1. Database Connection Issues
Symptom: Connection refused (500 Internal Server Error)
- Cause: The MySQL server is not running or the
DATABASE_URLis incorrect. - Solution:
- Ensure your local MySQL instance is running (
service mysql status). - Check your
.envfile for the correct connection string. - Verify that the database exists and the user has the necessary permissions.
- Ensure your local MySQL instance is running (
Symptom: Too many connections
- Cause: The connection pool is saturated, or connections are not being properly closed.
- Solution:
- Increase the
max_connectionsin your MySQL configuration. - Review your code for unclosed database connections.
- Adjust the connection pool settings in Drizzle.
- Increase the
2. Authentication Errors
Symptom: INVALID_TOKEN or Session Expired
- Cause:
AUTH_SECREThas changed, or the token has actually expired. - Solution:
- Re-authenticate via the login screen.
- Ensure the
AUTH_SECRETin your.envis stable and has not been rotated unintentionally. - Check the clock synchronization on your server instances.
Symptom: CSRF error / Forbidden
- Cause: Cross-Site Request Forgery protection is blocking the request.
- Solution:
- Ensure the
BETTER_AUTH_URLmatches the frontend's origin precisely. - Check if the frontend is correctly sending the necessary auth headers or cookies.
- Ensure the
3. Build & Nx Monorepo Issues
Symptom: Cannot find module '@tower-defense/...'
- Cause: The project graph is out of date, or libraries have not been built.
- Solution:
- Run
pnpm installto update node_modules. - Run
pnpm nx resetto clear the Nx cache and rebuild the project graph. - Ensure the library exists in
libs/and is correctly referenced intsconfig.base.json.
- Run
4. Email Delivery Failures
Symptom: No emails received during development.
- Cause: smtp4dev is not running, or the SMTP configuration is incorrect.
- Solution:
- Start smtp4dev and check its web interface at
http://localhost:63384. - Verify
SMTP_HOSTandSMTP_PORTin your.envfile.
- Start smtp4dev and check its web interface at
tip
Still stuck? Open a new issue in our repository or reach out to the development team on Discord/Slack.