0

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.

3
  • 2
    You need to check webserver / application logs to find out the actual cause of error 500. Http error 500 simply means that the server encountered an unhandled error and terminates the execution of your app. You may have to turn on exception logging within your app to get detailed enough information. Commented May 29 at 19:40
  • Hi, I'm trying to connect phpMyAdmin (deployed with Coolify) to a MySQL database on a VPS, but the connection fails. Everything seems correctly configured. I can access MySQL via terminal on the VPS using the same credentials (created via Coolify), and I can see databases and tables — so MySQL is running fine. However, when I try to log in via phpMyAdmin, I get one of the following errors: mysqli::real_connect(): (HY000/2002): No such file or directory or: php_network_getaddresses: getaddrinfo for mysql failed: Temporary failure in name resolution Commented May 30 at 10:29
  • I’ve tried entering in the "Server" field: localhost mysql container IP container name None of them worked. Any idea what I might be missing? Docker network config? Hostname resolution? Socket issue? Thanks in advance! Commented May 30 at 10:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.