Troubleshooting common problems
Use these examples to identify problems while building a Mojara application.
1. mojara: command not found
mojara --help
If your terminal cannot find the command, confirm the Mojara CLI is installed and included in your shell's PATH. Open a new terminal after installation.
2. Port already in use
If the server cannot bind its configured port, check which process is using it:
ss -ltnp | grep :8000
Stop the old process or choose an available port.
3. The browser shows 404
Confirm the method and URL match the route registration:
app.get("/about", about)
This registers GET /about, not POST /about and not GET /about-us.
Check:
curl -i http://127.0.0.1:8000/about
4. A form returns 422
Check the required fields and sent content type. For JSON, send:
curl -i -X POST http://127.0.0.1:8000/api/users \
-H "Content-Type: application/json" \
-d '{"email":"amina@example.com"}'
A missing field can cause a validation response even when the JSON syntax is correct.
5. A database connection fails
Check the hostname, port, username and database. For PostgreSQL:
pg_isready -h 127.0.0.1 -p 5432
For MySQL:
mysqladmin -h 127.0.0.1 -P 3306 ping
Verify that the database allows connections from the application host.
6. Nginx gives 502
If the reverse proxy cannot reach your app, confirm the app is running and listening on the port in proxy_pass:
curl -i http://127.0.0.1:8000/
sudo nginx -t
sudo tail -n 50 /var/log/nginx/error.log
7. An upload fails
Check form enctype="multipart/form-data", request-size limits, allowed MIME types and write permissions. See Uploads.