THE ORB
Starting the studio

Database connection failed (oxmysql / mysql-async)

Your server cannot reach its database. Nothing that saves or loads will work until this is fixed.

groupsNothing saves or loadspersonYou can fix this

Do this first

Check the database is running and that the connection line in server.cfg has the right username and password.

bug_reportPaste your whole console instead

What it means

The database layer could not reach MySQL, or reached it and was rejected. Every query in every resource will fail until this is fixed, so a wall of unrelated database errors under this one is expected and not worth reading yet.

The node error code tells you which half failed:

ECONNREFUSED — reached the host, nothing listening on that port

ETIMEDOUT — never reached the host at all (firewall, wrong IP)

ENOTFOUND / getaddrinfo — the hostname does not resolve

ER_ACCESS_DENIED_ERROR — reached MySQL, wrong user or password

ER_BAD_DB_ERROR — connected, but that database does not exist

What causes it

Ordered by how often it is the answer.

  1. 1

    MySQL is not running

    Most common on a local machine after a reboot, or on a fresh box where the service was never enabled.

  2. 2

    The connection string is wrong or malformed

    set mysql_connection_string must be one line, in server.cfg, before the resources that use it. Both formats work but the semicolon form is unforgiving about spaces:

    set mysql_connection_string "mysql://user:password@localhost/database?charset=utf8mb4"
  3. 3

    A password with special characters, unescaped

    @, :, / and # inside a password break the URI form. Percent-encode them or use the key/value form.

  4. 4

    The user has no rights from this host

    MySQL grants are per host. A user created as user@localhost cannot connect from another machine even with the right password.

  5. 5

    The database does not exist yet

    The connection succeeds and the USE fails. The framework's SQL was never imported.

How to tell which one is yours

Read the code, not the sentence. Then try connecting with the same credentials from the same machine:

mysql -h 127.0.0.1 -u youruser -p yourdatabase

If that fails too, the problem is MySQL and not FiveM. Note that localhost and 127.0.0.1 are not interchangeable in MySQL grants.

Where to look

server.cfg, the set mysql_connection_string line, and whether oxmysql is ensured before anything that queries.

How to fix it

# server.cfg — before every resource that touches the database
set mysql_connection_string "mysql://fivem:pass@127.0.0.1/fivem?charset=utf8mb4"
ensure oxmysql

Grant the user properly if it is remote:

CREATE USER 'fivem'@'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'%';
FLUSH PRIVILEGES;

Still stuck on your own code?

This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.

bug_reportOpen Server Fixer

Errors that travel with this one