SERVER
Server Setup

How to Fix MySQL Service Not Running ECONNREFUSED in FiveM

August 8, 2025 · 4 min read

When running a FiveM server, one of the most common issues you may encounter is the MySQL service not running, specifically showing the error ECONNREFUSED. This can prevent your server from connecting to databases, impacting essential features like player data and resource management. Understanding how to fix MySQL service not running ECONNREFUSED in FiveM is crucial for maintaining the functionality of your server, especially if you're using popular frameworks like ESX, QBCore, or QBox.

Understanding the Error

The ECONNREFUSED error indicates that your server cannot establish a connection to the MySQL database. This could be due to various reasons such as the MySQL service not running, incorrect configuration settings, or firewall restrictions.

Common Causes of ECONNREFUSED

  • MySQL Service is Down: The MySQL server might not be running at all.
  • Configuration Errors: Incorrect details in your connection settings can block access.
  • Firewall Issues: A firewall could be configured to block connections to the MySQL server.
  • Host Misconfiguration: If the hostname or port is set incorrectly, it can lead to connection issues.

Steps to Troubleshoot MySQL Connection Issues

When you encounter the ECONNREFUSED error, follow these troubleshooting steps systematically to identify and fix the issue.

1. Check if MySQL Service is Running

Firstly, ensure that the MySQL service is actually running. You can do this by:

  • On Windows:
    • Open Task Manager (Ctrl + Shift + Esc), go to the Services tab, and search for MySQL. You should see a status indicating if it's running.
    • Alternatively, you can open Command Prompt and type:
      net start | find "MySQL"
      
  • On Linux:
    • Use the following command in Terminal:
      sudo systemctl status mysql
      
      If it’s inactive, start it using:
      sudo systemctl start mysql
      

2. Verify Configuration Settings

Check your server.cfg and ensure your database connection details are correct. Look for the following lines:

  • set mysql_connection_string "mysql://user:[email protected]:3306/database"
    Make sure:
  • The username and password are accurate.
  • The hostname (127.0.0.1 for local connections) is correct.
  • The database name exists in MySQL.
  • Port 3306 is standard, but confirm if your MySQL uses a different port.

3. Review Your Resource Configuration

If you're using a framework like ESX or QBCore, check the related resource’s configuration file, usually found in:

  • resources/[your_resource]/fxmanifest.lua Look for how the MySQL connection is handled. Ensure it matches your server.cfg settings. If using an older system, check __resource.lua files as well.

4. Check Firewall Settings

Sometimes, a firewall can block MySQL from accepting connections:

  • Windows Firewall:
    • Go to Control Panel > System and Security > Windows Defender Firewall > Advanced Settings.
    • Create a new Inbound Rule allowing TCP connections on port 3306.
  • Linux Firewall (e.g., iptables):
    • Use:
      sudo iptables -L
      
    • To allow MySQL through:
      sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
      

5. Verify Database Driver Installation

If none of the above steps work, ensure that the appropriate MySQL driver is installed for your framework. For instance, ESX typically uses mysql-async:

  • Check if mysql-async is running by visiting your resources folder.
  • Look for the file mysql-async in your fxmanifest.lua and ensure it is correctly referenced:
    dependency 'mysql-async'
    

6. Restart Services

After making changes, restart your MySQL service. Use the commands mentioned earlier, and also restart your FiveM server to ensure settings refresh.

Checklist to Troubleshoot ECONNREFUSED

  • MySQL service is running.
  • Connection details in server.cfg are correct.
  • Resource configuration matches server settings.
  • Firewall settings allow MySQL connections.
  • Database driver is properly installed.
  • Services have been restarted after configuration changes.

When to Seek Further Help

If you’ve followed all these steps and still face issues, consider checking community forums or documentation for your specific framework (ESX, QBCore, or QBox) for any known issues or additional support resources. Additionally, you can look into scripts or add-ons that enhance database performance or connectivity such as those available in our scripts category.

Frequently Asked Questions

Q1: What is the default port for MySQL?
A1: The default port for MySQL is 3306. Make sure this port is open in your firewall settings.

Q2: Can I use a remote MySQL server?
A2: Yes, but ensure that your connection string points to the correct IP address and that remote connections are allowed in your MySQL configuration.

Q3: How do I know if my MySQL database is running correctly?
A3: You can connect using a database management tool like phpMyAdmin or MySQL Workbench to verify your database is functioning.

Q4: What if I keep getting connection errors?
A4: Double-check your configuration settings and consider looking into server logs for more detailed error information.

By following these guidelines, you should be able to resolve the ECONNREFUSED error effectively, ensuring smooth operation of your FiveM server and enhancing player experiences.

#fivem#mysql#ecconnrefused#server setup#troubleshooting

Keep reading