Skip to content

FiveM: Fix Database Connection Issues

Learn how to fix database connection issues on your FiveM server and restore smooth communication with your database

29 November 20262 min read78 Views0 helpful

Don't have your own server yet? Host your FiveM server with ZAP-Hosting from €5.29 / month.Or try 3 days from €0.95

Introduction

Oxmysql is a useful open-source FiveM resource that is already preinstalled on your FiveM game server to enable communication between the server and the database. During development, you may make changes (e.g., updating the database credentials) that require you to adjust the oxmysql connection string. Typical signs include oxmysql error messages in the server console, such as EHOSTUNREACH (database server unreachable) or the MySQL error 1045 (credentials rejected), and resources that need the database but do not start properly.

In this guide, we’ll show you how to fix database connection issues on your FiveM game server by adjusting the connection string in your server configuration file.

Automatic method

You don’t need a dedicated button for this: If you reset a database password using Reset password in the Databases tab of your game server, ZapX automatically adds the new password to your server.cfg when the server is set up again afterward. For the primary database of a running server, this happens immediately after the reset.

This only works as long as the connection string still contains your server’s database user. If you’ve entered your own credentials or a different database there, or the errors persist, adjust the line yourself as described below.

You can also do this in chat with the ZapX AI Agent: If oxmysql reports the error 1045 or EHOSTUNREACH, it corrects the line in your server.cfg using a card and only inserts the actual credentials after you confirm. Learn more: FiveM: Manage your server with the ZapX AI Agent.

Manual method

To fix this manually, you need access to your server.cfg file, where you can manually update the connection string with the credentials from your web interface. Sign in to the txAdmin dashboard and open the CFG editor. In another tab, open the Databases tab of your game server, where you can find your current credentials.

Add the following line to your server.cfg (or replace it if it already exists) and enter your own database credentials from the web interface:

Code
set mysql_connection_string "mysql://USER:PASSWORD@HOST:PORT/DATABASE"

You can find the values in the User, Password, Host, Port, and Database fields in the Databases tab. The port is usually 3306, but may vary.

Then save the file and restart your server.

Conclusion

The next time your server starts, your game server should be able to access the database without any issues, and everything should work as usual. You’ve successfully resolved your database connection issues. If you have any other questions or need help, our support team is available every day! 🙂

Free tools

FiveM Tools

View all

FAQ

Frequently asked questions

If you reset the password using “Reset password” in the Databases tab, ZapX will automatically add the new password to server.cfg, as long as your server's database user is still listed there. There is no dedicated button for this; otherwise, update the line yourself in the txAdmin CFG editor.
Oxmysql is an open-source FiveM resource that comes preinstalled and enables communication between the server and the database.
Log in to the txAdmin dashboard, open the CFG editor, and update the connection string in server.cfg with the current credentials from your game server's Databases tab.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.