Contents
The app works on your computer; after the upload it stops or returns a 503, and the log shows a line such as Error: connect ECONNREFUSED 127.0.0.1:3306. In PHP the same problem reads SQLSTATE[HY000] [2002] Connection refused (MySQL 2002), and in WordPress Error establishing a database connection. The number after the colon is the port, and it’s the most useful part of the message.
Read the address and port in the message
| In the message | What it means |
|---|---|
127.0.0.1:3306 |
Connecting to MySQL locally, but the settings or address don’t match the server |
::1:3306 |
localhost resolved to an IPv6 address |
127.0.0.1:5432 |
The project was written for PostgreSQL |
127.0.0.1:27017 |
The project was written for MongoDB |
A name such as db or mysql |
A Docker setting from the developer’s machine |
The most likely causes, in order
1. Connection settings from development
AI tools often write DB_HOST=db or DB_HOST=mysql (Docker service names), or a test cloud database, or leave .env out of the upload so no values are read.
Fix: set the variables under Environment variables on the app’s page in Setup Node.js App or Setup Python App:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=USER_appdb
DB_USER=USER_appuser
DB_PASSWORD=...
Then Restart. If the values don’t reach the code, see env not loaded.
2. localhost resolves to ::1
Since Node.js 17, localhost may resolve to the IPv6 address ::1 first, and if MySQL isn’t listening there you get ECONNREFUSED ::1:3306.
Fix: use 127.0.0.1 instead of localhost in DB_HOST or DATABASE_URL. In PHP try both, since localhost there means a socket file.
3. A database type the hosting doesn’t have
What you see: port 5432 or 27017.
Fix: the hosting provides MySQL/MariaDB. Switch the project to MySQL (in Prisma change provider, as in Prisma errors), use the cloud service’s HTTPS library where it has one (a direct connection to an external database port is not available from ArabyHost), or choose a VPS for a database the hosting doesn’t offer.
4. The database or user doesn’t exist yet
Fix: in cPanel open MySQL Databases: create the database, then the user, then add the user to the database with ALL PRIVILEGES. Full names start with the account prefix, such as USER_appdb (guide). If the error then changes to Access denied, see MySQL 1045.
5. Connecting from outside the server
If the app runs on Vercel or your laptop and connects to the hosting database, it will not connect: on ArabyHost the MySQL port is not open to the internet. Run the app and its database on the same server, or reach the database through an SSH tunnel on a plan with SSH.
How to confirm it’s fixed
Over SSH, try the same credentials:
mysql -h 127.0.0.1 -u USER_appuser -p USER_appdb -e "SELECT 1;"
If it prints 1, the credentials work, and after Restart the error disappears from the app’s log.
Prevention
- Read every database setting from environment variables; never hard-code them.
- Develop on MySQL if production runs MySQL.
- Keep a
.env.examplelisting the variables the app needs.
On ArabyHost
On ArabyHost you create MySQL/MariaDB databases in cPanel’s MySQL Databases on every plan, and Node.js and Python apps on AI/Developer plans run on the same server, so they connect to 127.0.0.1 or localhost. The connect your app to a database guide walks through it, and Araby AI reads the error log and explains the fix.
FAQ
What's the difference between ECONNREFUSED and Access denied?
ECONNREFUSED means the connection never reached the database server, so the username and password weren't checked yet. `Access denied` (error 1045) means the server answered and rejected the login.
Can I connect to the hosting database from my computer?
On ArabyHost the MySQL port (3306) is not open to the internet, so an app on your laptop cannot connect to the hosting database directly. Develop against a local database and import the data through phpMyAdmin, or use an SSH tunnel on a plan with SSH.
My app uses Supabase or MongoDB. Do I have to move it?
From ArabyHost outgoing connections are HTTPS only. Supabase keeps working through its HTTPS library or REST API, but a direct connection to an external PostgreSQL or MongoDB server is refused or times out. Move the data to MySQL on the hosting, or choose a provider or VPS that offers the database you need.