I’m encountering an issue while deploying a website built with Next.js and a MySQL database, hosted on a Hostinger VPS using Coolify.
Context: • The Next.js site is properly built (next build) and deployed from a Git repository via Coolify. • The MySQL database is installed (either locally or in a container), and port 3306 is open. • Environment variables are set correctly (DB_HOST, DB_USER, DB_PASS, NEXT_PUBLIC_URL, etc.). • The application deploys successfully on Coolify, no errors appear during startup. • However: the frontend fails to fetch data → API calls return a 500 Internal Server Error.
Question:
How can I accurately isolate the cause of the 500 error when trying to fetch data from the database in Next.js? Are there any known issues or specific configurations with MySQL and Coolify that could cause this?
Thanks in advance for your help 🙏
What I’ve already checked: • The MySQL connection works via terminal (mysql -h ...) • Coolify/Next.js logs show the error comes from an API endpoint. • No obvious issues in the .env file, all variables are filled in. • Even a minimal test endpoint (/api/test.js) returns a 500 error.