Fix connect ECONNREFUSED 127.0.0.1:3306 in FiveM oxmysql
connect ECONNREFUSED 127.0.0.1:3306 means nothing accepted oxmysql on port 3306. Start MariaDB, check its port and bind address, then fix the connection line.
- Applies to
- FiveM Legacy and FiveM for GTAV Enhanced servers; oxmysql 2.14.3 (October 6, 2026) on its Node.js 22 runtime; MariaDB on Windows, Debian and Ubuntu; txAdmin Recipe Deployer (source of October 23, 2026); Qbox, ESX Legacy 1.16.4 (October 18, 2026) and QBCore
- Last verified
On this page
- Direct Answer
- What “connect ECONNREFUSED 127.0.0.1:3306” means
- Where the error shows up and what each version tells you
- Why nothing accepts connections on port 3306
- How to fix ECONNREFUSED 127.0.0.1:3306 step by step
- localhost, 127.0.0.1 and ::1
- A database at a game host, on another server or in a container
- Troubleshooting
- Next Steps
Direct Answer
connect ECONNREFUSED 127.0.0.1:3306 means a connection to port 3306 on the machine or container FXServer runs in was refused before any login took place. Node.js, which oxmysql runs on, uses this code when the target “actively refused” a connection, usually because the service is inactive. Fix it in this order: start MariaDB (net start MariaDB on Windows, sudo systemctl start mariadb.service on Linux), read its port, bind address and skip-networking setting in my.ini or my.cnf, make the host and port in mysql_connection_string match, then restart the server. A database at a game host, in a container or on another machine needs that server’s address instead of 127.0.0.1.
What “connect ECONNREFUSED 127.0.0.1:3306” means
oxmysql describes itself as a FiveM resource “to communicate with a MySQL database using node-mysql2”. Before node-mysql2 can send a login or a query, it opens a TCP connection to the host and port from your connection string. ECONNREFUSED is the Node.js error for a refusal at that first step:
ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
The rest of the text follows the Node.js system-error fields: connect is the system call that failed, 127.0.0.1 the address and 3306 the port. Three facts make the message easy to read:
- 127.0.0.1 is the loopback address of the machine that connects. MariaDB’s documentation explains that a server bound to it “will only accept connections originating from the server machine itself via the loopback interface”.
- 3306 is MariaDB’s built-in default port, and node-mysql2 also uses 3306 when your line names no port.
- No login has happened yet. MariaDB’s troubleshooting guide treats “Server Not Running or Incorrect Location” apart from authentication problems, where the “Connection is established, but authentication fails”. The password and database name only matter once something answers on the port.
ECONNREFUSED compared with the other codes oxmysql prints
| Code in the error | What it means | Where to look |
|---|---|---|
ECONNREFUSED | The target machine “actively refused” the connection (Node.js) | MariaDB is stopped, on another port, or not listening on that address |
ETIMEDOUT | The other side “did not properly respond after a period of time” (Node.js) | A wrong IP, or a firewall on the way to a remote database |
ENOTFOUND | “DNS lookup failed” (Node.js) | The host name in your line |
ER_ACCESS_DENIED_ERROR | MariaDB error 1045: the login failed | User name, password or account host |
ER_BAD_DB_ERROR | MariaDB error 1049: Unknown database | The database name in your line |
The last two are answers from MariaDB itself, so the port is open. The troubleshooting section below covers each code.
Where the error shows up and what each version tells you
oxmysql: “Unable to establish a connection to the database (ECONNREFUSED)”
oxmysql 2.14.3, released October 6, 2026, connects as soon as it starts. When that fails, the server console shows Unable to establish a connection to the database (ECONNREFUSED)! with the error code in parentheses. The next line starts with Error, followed by the error number when there is one and the Node.js message. oxmysql then points to its common-issues list (issue 154 in its repository) and prints the connection settings it used, with the password replaced by ******. That printout shows what oxmysql actually took from your line, so compare its host and port with where MariaDB really runs.
oxmysql does not give up after a failure. It waits 30 seconds and tries again, in a loop, until a connection works. On success it prints the database server’s version in square brackets, followed by Database server connection established!.
txAdmin Recipe Deployer: “Database connection failed”
When a recipe has database tasks, as the Qbox, ESX Legacy, StreetKings and WarfareTacticsV recipes do, txAdmin tests the database login before it runs anything. The fields sit behind Show/Hide Database options (advanced). Their defaults are host localhost, port 3306, user root and an empty password, and the test gives up after 5000 ms.
A refused connection comes back as Database connection failed: followed by the Node.js message and a hint that depends on the operating system:
- Windows: “If you do not have a database installed, you can download and run XAMPP.”
- Linux: “If you do not have a database installed, you must download and run MySQL or MariaDB.”
- Any port other than 3306 adds “You are not using the default DB port 3306, make sure it is correct!”
Ignore the XAMPP hint. The oxmysql documentation says “Do not setup XAMPP just to run your database, and install MariaDB directly instead”, the ESX install guide says “Do not use XAMPP”, and the Qbox installation page says “XAMPP IS NOT SUPPORTED”. If no database server is installed yet, start with the FiveM database setup guide. The txAdmin recipe guide covers the other deployer steps.
ESX: “OxMySQL Was Unable To Connect to your database”
On ESX Legacy 1.16.4 (October 18, 2026), players who try to join while oxmysql has no connection are rejected with this text:
[ESX] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg
esx_multicharacter sends the same sentence with an [ESX Multicharacter] prefix. es_extended only marks its database as connected once oxmysql reports that it is ready, so the player message is a symptom. The cause is in the oxmysql lines of the server console. If the connection line is empty, esx_multicharacter also stops with “Unable to start Multicharacter - unable to determine database from mysql_connection_string”.
Older resources: mysql-async and ghmattimysql
Errors tagged script:mysql-async or script:ghmattimysql come from older database resources. A typical forum report reads [ script:ghmattimysql] [ERROR] connect ECONNREFUSED 127.0.0.1:3306. The cause is the same refused port. oxmysql’s documentation says you can delete both resources “and allow oxmysql to provide their functionality”; its manifest declares provide 'mysql-async' and provide 'ghmattimysql'.
Why nothing accepts connections on port 3306
MariaDB’s troubleshooting guide names the two basic cases: the server “may not be running”, or it “is running, but not on the specified host, port, socket, pipe, or protocol”. In a FiveM setup that comes down to these causes:
| Cause | How it shows | Fix |
|---|---|---|
| MariaDB is stopped, failed to start or was never installed | The service is not running; mariadb-admin status cannot connect | Start it, and read its error log if it stops again |
| MariaDB uses another port | The [mysqld] section says port=3307 while your line has no port | Add the port after the host |
| TCP is turned off | skip-networking is set, or the Windows installer ran with Enable networking unticked | Comment out skip-networking and restart MariaDB |
| MariaDB listens on another address | bind-address names an IP other than the one in your line | Connect to an address MariaDB listens on |
| The database is not on this machine | A game host, a container panel or a second server | Use the database server’s address |
| MariaDB starts after FXServer | The first attempt after a reboot fails, a later retry connects | Make MariaDB start at boot |
A port mismatch can start at installation: Qbox’s migration guide notes that if an old database server already uses 3306, the MariaDB installer suggests 3307. The Windows installer’s Enable networking step decides “Whether to enable TCP/IP (recommended) and which port MariaDB should listen to”. Untick it and “the database will use named pipes for communication”, so no TCP port is open for oxmysql.
How to fix ECONNREFUSED 127.0.0.1:3306 step by step
The steps are the same on FiveM Legacy and FiveM for GTAV Enhanced. oxmysql’s manifest declares game 'common', the Enhanced recipe list points to the same ESX Legacy and Qbox recipes as the Legacy list, and Cfx.re’s page on what changed in Enhanced has no entry about MariaDB or the Node.js runtime (its only database item is the migration of FXServer’s key-value DB files). Qbox, ESX Legacy and QBCore servers all connect through the same mysql_connection_string line.
-
Read the whole error. Note the code in parentheses, the address and port in the message, and the host in oxmysql’s settings printout. If the database runs somewhere other than that address, go to the section on game hosts, other servers and containers further down.
-
Check that MariaDB is running. On Windows, the MariaDB installer’s default service name is
MariaDB; the installer also lets you choose another name, so use yours if you changed it. Runsc.exe query MariaDBin a Command Prompt and read the STATE line, or check the Services list, as ESX’s guide suggests. To start it, open a Command Prompt as administrator and runnet start MariaDB. On Linux with systemd, the service ismariadb.service:sudo systemctl status mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.serviceThe last command makes MariaDB start at boot.
-
If MariaDB stops again, read its error log. Where it goes depends on
log_error. When that option is set without a file name, MariaDB writes a file named after the host with the.errextension in its data directory. On Linux, when it is not set, the messages go to stderr, and under systemd MariaDB describes the journal (journalctl) as “a good place to look when a failure has occurred”. On Windows, the messages also appear in Event Viewer under Windows Logs, then Application. -
Find the port and address MariaDB is set to use. Open the configuration file and look in the
[mysqld]section forport,bind-addressandskip-networking.mariadbd --help --verboselists which option files the server reads, in order. An option file can also include every file in a directory; packaged files carry numeric prefixes such as50-server.cnf, and when an option is set twice, the file read last wins.my_print_defaults --mariadbdprints the server options from all of these files at once.Windows Debian and Ubuntu Configuration file my.iniin the data directory, for exampleC:\Program Files\MariaDB X.X\data\my.ini/etc/mysql/my.cnfBind address in the sources Qbox’s sample my.inihasport=3306and nobind-addresslineMariaDB: bind_addressis set to127.0.0.1Restart after an edit net stop MariaDB, thennet start MariaDB, as administratorsudo systemctl restart mariadb.serviceIf
skip-networkingis active, MariaDB’s instruction is to “comment it out or set it to 0”, then restart.The sources describe the default address differently. MariaDB’s variable reference says the server “listens for TCP/IP connections on all addresses” unless told otherwise, and that Debian and Ubuntu set 127.0.0.1. Qbox’s remote-access article says “By default, MariaDB only listens on localhost (127.0.0.1).” Read your own file rather than assuming either.
-
See what really listens on the port. On Windows, run this in a Command Prompt:
netstat -ano | findstr :3306-aincludes the ports “on which the computer is listening”,-nkeeps addresses numeric and-oadds the process ID, which Task Manager’s Processes tab can match to a program. On Linux,sswith-t(TCP),-l(listening only),-n(numeric) and-p(show the process) does the same:sudo ss -tlnpNo listening entry with
:3306means nothing listens on that port. An entry for127.0.0.1:3306means MariaDB accepts connections from this machine only. -
Test the port without FXServer. MariaDB’s troubleshooting guide shows what its own client prints for the same failure:
mariadb -u someuser -p --port=3307 --protocol=tcp ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (111 "Connection refused")Run that command with your own user and port.
--protocol=tcpmatters: node-mysql2 always connects over TCP unless a socket path is set, while MariaDB’s own tools reachlocalhoston Linux through the socket file, as itsmariadb-admin statusexample shows, so they can work while TCP is off. On Windows, HeidiSQL is the easier test: Network type “MariaDB or MySQL (TCP/IP)”, Hostname / IP127.0.0.1and the port from step 4. -
Make
mysql_connection_stringmatch. The oxmysql documentation accepts two formats inserver.cfg:set mysql_connection_string "mysql://root:12345@localhost:3306/fivem" set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=fivem"Keep one line, with your own user, password and database name.
- Put the port after the host when it is not 3306, as in Qbox’s example
mysql://root:YourPassword@localhost:3307/qbox_migration?charset=utf8mb4, or setport=in the other format. txAdmin writes a port into the line only when it differs from 3306, so a deployer-made line without one means 3306. - Use
set. The oxmysql docs: “Make sure you only ever use set.” - Keep the order. Set the line “before starting any resources” and add
start oxmysql“to the top of your resource list”. - Old key names still work. oxmysql rewrites
server=,ip=andaddress=tohost=,uid=touser=,pwd=topassword=anddb=todatabase=, so a mysql-async line such asserver=localhost;uid=...keeps working.
- Put the port after the host when it is not 3306, as in Qbox’s example
-
Restart and read the console. oxmysql reads the connection line once, when it starts, so a change in
server.cfgneeds a server restart. If the only fix was starting MariaDB, a running server reconnects by itself at the next 30-second retry. The fix worked whenDatabase server connection established!appears.
localhost, 127.0.0.1 and ::1
127.0.0.1 is the IPv4 loopback address and ::1 its IPv6 form. MariaDB’s error 1130 page says that when skip_name_resolve is on, a TCP connection from the same machine “arrives as 127.0.0.1 or ::1”, so a local connection can use either loopback address. On Debian and Ubuntu, MariaDB’s bind_address “is set to 127.0.0.1, which binds the server to listen on localhost only”, which covers the IPv4 address alone.
Whether localhost can end up at ::1 first depends on the Node.js version that makes the connection:
- FiveM’s default for server scripts is Node.js 16, and oxmysql 2.14.3 opts into version 22 with
node_version '22'. - Node.js 17 changed name lookups so that, by default, addresses come back in the order the resolver returns them instead of IPv4 first.
- Node.js 20 made
autoSelectFamilythe default. A connection then tries “all obtained IPv6 and IPv4 addresses, in sequence”, and “Connection errors are not emitted if at least one connection succeeds.” If every attempt fails, Node.js emits “a single AggregateError with all failed attempts” instead of one error per address.
With current oxmysql and Node.js’s defaults, localhost therefore still reaches a MariaDB that listens only on 127.0.0.1, as long as the name resolves to that address. If an error names ::1, the IPv6 loopback refused the connection: write 127.0.0.1 as the host so the connection uses IPv4.
The host also matters for the login, and MariaDB’s own pages describe it differently. The CREATE USER reference says that on Linux “the loopback interface (127.0.0.1) will not match ‘localhost’”, so only Unix-socket connections match. The error 1045 page says “When skip_name_resolve is off, a TCP connection to 127.0.0.1 is also reported as localhost.” Go by the host printed in an access-denied message, and make sure an account exists for exactly that host. In the account list shown in Qbox’s remote-access article, root exists for the hosts 127.0.0.1, ::1, computer and localhost, so that server has a root account for each loopback address.
A database at a game host, on another server or in a container
127.0.0.1 only ever reaches the machine or container that makes the connection. When the database lives anywhere else, the line needs that server’s address.
-
Game server hosts. txAdmin’s
TXHOST_*variables are “usually required for Game Server Providers (GSPs)”, andTXHOST_DEFAULT_DB<HOST|PORT|USER|PASS|NAME>pre-fills the deployer’s database fields. Those values “can be overwritten during manual deployment or after that by modifying their server.cfg”. If the line was changed tolocalhost, put back the host, port and login your provider gave you. -
Container panels. Pterodactyl’s site states: “Every server runs in its own Docker container”. Docker’s networking reference makes the point for its DNS option that inside a container,
127.0.0.1“refers to the container’s own loopback address”. On Docker’s defaultbridgenetwork, a line with127.0.0.1therefore reaches the container, not the machine’s MariaDB; only thehostdriver would “Remove network isolation between the container and the Docker host”. Use the database address your panel or provider lists. -
Your own second machine. MariaDB must listen on an address FXServer can reach. MariaDB’s guide says to comment out
bind-addressor “set it to a specific public IP address of the server”; MariaDB 10.11 and later also accept a comma-separated list. Qbox’s article setsbind-address = 0.0.0.0and pairs it with a strict firewall: “Never open port 3306 (default MariaDB port) to the entire internet.” On Linux it allows only the fixed IP of the machine that needs access:sudo ufw allow from 203.0.113.7 to any port 3306 proto tcp sudo ufw reloadOn Windows, Qbox’s equivalent is an inbound
New-NetFirewallRulefor TCP port 3306 with-RemoteAddressset to that machine’s address, run in PowerShell opened as administrator.MariaDB also needs an account for the host it sees; when no account matches that host at all, it answers with error 1130. Qbox adds that a DDoS provider in front of the database machine “might block connections on non-gaming-related ports”. The Linux server guide covers running FXServer and MariaDB on a VPS.
Troubleshooting
“Empty mysql_connection_string detected”
This message comes from mysql-async, not oxmysql. mysql-async 3.2.3 (May 23, 2020) printed it when the convar was not set. By 3.3.2 (July 19, 2020), mysql-async fell back to mysql://root@localhost/fivem instead. oxmysql 2.14.3 never prints it. With no line it tries the DB_CONNECTION environment variable, then mysql://root@localhost, which is root with no password and no database. Replace mysql-async with oxmysql and add a set mysql_connection_string line before any resource starts.
“ER_ACCESS_DENIED_ERROR” or “Access denied for user ‘root’@‘localhost’”
oxmysql shows (ER_ACCESS_DENIED_ERROR) and Error 1045, the name node-mysql2 gives MariaDB’s error 1045. The port answered; the login failed. According to MariaDB, “a wrong password, a missing password, and a user name that has no account all give the same error”. using password: YES only means a password was sent, and using password: NO means none was.
- Check the password in the line. If it contains one of the reserved characters oxmysql lists,
; , / ? : @ & = + $ #, try the other format or change the password. - Check that an account exists “for the user and the host that the error message names”, with
SELECT User, Host, plugin FROM mysql.user WHERE User='app';and your own user name in place ofapp. - Look for an anonymous account. MariaDB picks the most specific host first, so
''@'localhost'“wins over ‘app’@’%’ for a local connection” and the right password still fails. MariaDB removes it withDROP USER ''@'localhost';ormariadb-secure-installation. - On Linux, a
rootaccount that usesunix_socketgives error 1698 instead, without theusing passwordpart. MariaDB’s quick fix is to log in withsudoonce and create a proper user. The database setup guide walks through that account.
“Unknown database” in FiveM (ER_BAD_DB_ERROR)
When your line names a database, oxmysql connects with it as the default database: it sets node-mysql2’s CONNECT_WITH_DB flag. A name that does not exist on the server then fails in the same “Unable to establish a connection” message, with ER_BAD_DB_ERROR, MariaDB error 1049: Unknown database. An account without privileges can get error 1044 for the same mistake (next entry). In HeidiSQL, “The list on the left shows every database on the server”. Compare it with the name in mysql_connection_string, then fix the name or create the database.
“Access denied for user … to database” (ER_DBACCESS_DENIED_ERROR)
This is error 1044. The account “has no privileges on the database it tries to use”. MariaDB returns the same error “for a database that doesn’t exist”, so a typing mistake in the database name can look like a missing privilege. Run SHOW GRANTS as that user, and have an administrator grant privileges on the database, as in MariaDB’s example GRANT SELECT, INSERT ON shop.* TO 'p'@'localhost'.
“Host ’…’ is not allowed to connect to this MariaDB server”
Error 1130 means no account at all matches the host FXServer connects from. MariaDB checks the host “before it reads the user name or the password”, and the message names the host it sees. Create an account for that host or network, as in MariaDB’s example CREATE USER 'app'@'192.168.1.%' IDENTIFIED BY '…';.
“connect ETIMEDOUT” instead of ECONNREFUSED
Nothing answered in time. Node.js uses ETIMEDOUT when “the connected party did not properly respond after a period of time”, and node-mysql2 raises its own connect ETIMEDOUT when its connect timeout runs out, which oxmysql sets to 60000 ms (60 seconds). Check the IP address first, then any firewall between FXServer and the database: MariaDB notes that a firewall on the database server “might block incoming connections on MariaDB’s port”. The txAdmin deployer’s own test waits only 5000 ms before it reports a failure.
“getaddrinfo ENOTFOUND” instead of ECONNREFUSED
The host part of the line could not be resolved: Node.js describes ENOTFOUND as “DNS lookup failed”. One forum report shows getaddrinfo ENOTFOUND my ip database:3306, a placeholder that was never replaced. Compare the host in oxmysql’s settings printout with what you meant to write. If they differ, oxmysql read your line differently than you intended. Its documentation lists the reserved characters to avoid and advises to “try swapping connection string format”.
The error appears after every reboot, then stops
FXServer started before MariaDB was ready. oxmysql retries every 30 seconds, so it connects once MariaDB is up; until then, ESX turns joining players away with the message above. On Linux, run sudo systemctl enable mariadb.service. On Windows, make sure MariaDB was installed as a service; its installer page calls running the database as a service the recommended setup.
“No such export … in resource oxmysql”
This is not a connection error: the resource that calls oxmysql cannot find it. oxmysql’s common-issues list gives the reasons, for example that oxmysql “has not yet started when you called the export”, and the fix: “Download the latest release and ensure it is the first resource in your resource start order.” oxmysql 2.14.3 also lists /server:12913 in its manifest, which means it needs FXServer build 12913 or newer. The No such export guide and the Couldn’t start resource guide cover the rest.
Next Steps
- Install MariaDB, create a database and user and import SQL files with the FiveM database setup guide.
- Set the remaining options of the connection line with the oxmysql connection string guide.
- For a VPS, the FiveM Linux server guide covers FXServer and MariaDB on Ubuntu and Debian.
- If oxmysql itself does not start, work through the Couldn’t start resource guide.
Browse FiveCrate assets
Original FiveM assets made in-house, with free updates and a multi-server license.
Official documentation and repository references
- Overextended Docs: oxmysql
- oxmysql on GitHub (overextended)
- oxmysql issue 154: Common issues
- txAdmin source: Recipe Deployer database check
- Qbox Docs: Remote database access
- Node.js Docs: Errors (common system errors)
- MariaDB Docs: Connection Troubleshooting Guide
- MariaDB Docs: Configuring MariaDB for Remote Client Access
Related guides
FiveM Database Setup: MariaDB and HeidiSQL Guide
FiveM database setup step by step: install MariaDB instead of XAMPP, create a database and an account, connect HeidiSQL and oxmysql, then import SQL files.
FiveM Server Linux Setup on Ubuntu and Debian (2026)
FiveM server Linux setup for Ubuntu and Debian: install FXServer, run txAdmin over SSH, open ports with ufw and keep the server online with tmux or systemd.
Fix 'No Such Export in Resource' Errors in FiveM
Fix 'No such export in resource' in FiveM: find why the export is missing, then check the resource name, start order, client or server side and version.
oxmysql Setup: mysql_connection_string Explained
Set mysql_connection_string for oxmysql 2.14.3: both formats, password characters, set vs setr, pool options, slow query warnings, debug convars and fixes.
txAdmin Recipes Explained: Deploy Qbox, ESX or Default
How a txAdmin recipe builds a FiveM server: the current Popular Recipes list, each deployer step, database options, custom URLs and the QBCore deprecation.
