FiveM error ECONNREFUSED 127.0.0.1:3306
Your console fills up with this line, and every script that touches the database fails:
Error: connect ECONNREFUSED 127.0.0.1:3306
127.0.0.1 means "this machine". The resource is looking for a MySQL server inside your game server itself, and there is none. Our databases run on a separate database server, so the connection is refused before it reaches anything.
This is what an unedited mysql_connection_string from a tutorial or a fresh oxmysql config looks like. Replacing it with your own connection details fixes it.
Copy the Connection String
- In the game panel, open your server and click Databases under MANAGEMENT. No database yet? Create one first.
- Press the Connection string button on your database card and copy the URI at the top. It carries the host, port, username, password and database name in one line.
Paste It into the server.cfg Editor
- Click server.cfg Editor under GAME SERVER and scroll to the Database section on the Settings tab.
- Paste the string into the Host field. The editor recognizes it and fills Host, Port, Username, Database and Password in one go.
- Check that Host is the IP address from the Databases page. It is never
127.0.0.1and neverlocalhost. - Press Save changes.
Restart and Watch the Console
- Restart your server from the Console page so the new connection string is loaded.
- The ECONNREFUSED lines are gone and oxmysql reports a working database connection during startup.
Editing server.cfg by Hand
If you prefer the Raw cfg tab or run FiveM on a VPS, the line looks like this:
set mysql_connection_string "server=45.8.187.109;port=3306;uid=u83519_example;password=yourpassword;database=s83519_example"
The Connection string window also hands you this exact line under server.cfg (key=value), so you rarely have to type it.
Finished
Still refused after a restart? A different address in the error means a different problem: check that the host, username, password and database name all come from the same card. The full walkthrough lives in connect your server to a database.
Czy to rozwiązało twój problem?
Dalej nie działa?
Nasz zespół wsparcia naprawdę zna gry, które hostujemy. Otwórz ticket, rozwiążemy to razem.
Otwórz ticket