MySQL Error 10061 means the client connection to the MySQL server was refused because the service, port, or network access blocked the request.
Seeing this MySQL 10061 connection error message when you connect can stop your app, your local project, or a production site in an instant. The good news is that this error usually points to a small set of server, port, or network settings, so a methodical check often brings MySQL back online within minutes.
This guide explains what error 10061 in MySQL really means, how it differs from other connection problems, and the exact checks you can run on Windows, macOS, and Linux. You will also see how to fix the error for localhost setups and remote database servers, plus habits that reduce the chance of seeing this code again. You do not need deep networking skills for these checks, only basic access to your system and MySQL tools and simple utilities.
MySQL Error 10061 Connection Refused Explained
In most clients the full message looks similar to Can't connect to MySQL server on 'localhost' (10061) or Connection refused (10061). The number 10061 comes from the Windows networking stack and means the target host actively rejected the connection.
When error 10061 in MySQL appears, the client managed to reach the host and port, but the server on that port refused the session. That is different from a timeout error such as 10060, where the request never reaches a listening service at all.
With MySQL, this refusal usually happens because the database server is not running, not listening on the expected port, accepting only socket or named pipe connections, bound only to a specific interface, or blocked by a firewall rule.
| Scenario | Typical Message | Likely Cause |
|---|---|---|
| Localhost on Windows | Can't connect to MySQL server on 'localhost' (10061) |
MySQL service stopped or not installed as a service |
| Local client to remote host | Can't connect to MySQL server on 'host' (10061) |
Port 3306 closed, bind address wrong, or firewall blocks traffic |
| GUI client such as Workbench | Host '127.0.0.1' port 3306: Connection refused (10061) |
Local MySQL server not running or not listening on that port |
Common Causes Of MySQL 10061 Error On Windows
On Windows desktops and servers, this 10061 error tends to come from a handful of repeat offenders. Before you change configuration files, it helps to know which ones show up most often.
- MySQL service not running — The MySQL server process is stopped, so no program is listening on port 3306 when the client connects.
- Wrong host or port — The client points to
localhost,127.0.0.1, or a remote IP while the server listens on another address or port. - Bind address too strict — The
bind-addressoption inmy.iniormy.cnfrestricts MySQL to a single interface, such as127.0.0.1, while you attempt a remote connection. - Firewall blocks TCP 3306 — Windows Defender or another firewall policy blocks inbound or outbound traffic to the MySQL port.
- skip-networking enabled — MySQL was started with networking disabled so it accepts only local socket or named pipe access.
- User not allowed from that host — The MySQL user account exists, but its host restriction does not match the IP or hostname you connect from.
Once you understand which of these patterns matches your setup, you can move through targeted checks instead of random trial and error.
Fixing MySQL 10061 On Localhost
When this 10061 error appears while you connect to localhost or 127.0.0.1, the root cause usually sits on your own machine. Work through these steps in order and try the connection again after each one.
- Confirm the MySQL service is running — On Windows, open Services, look for entries such as MySQL, MySQL80, or MariaDB, then start or restart the service. On macOS or Linux, use
systemctl status mysqldor your stack’s control panel. - Check which port MySQL listens on — Open your
my.iniormy.cnffile and locate theportsetting. If it is not 3306, update your client connection to match that port value. - Verify TCP listening with a local check — Run
netstat -an | find "3306"on Windows orss -ltnp | grep 3306on Linux to confirm that a MySQL process listens on the port you expect. - Review GUI client settings — In tools such as MySQL Workbench, check that the connection points to
127.0.0.1, the right port, and the correct user name, and that SSL options match the server configuration. - Inspect MySQL logs for startup failures — If the service will not start, open the MySQL error log and scan the latest entries for configuration errors or port binding problems, then fix those and restart the service.
- Reinstall or reconfigure as a service — When all checks fail and the service refuses to run, rerun the MySQL installer or stack installer, enable the Windows service option, and let the wizard apply a clean configuration.
In most local setups this 10061 error disappears once the service runs reliably on the right port and your client connection points to the same host, port, and user.
Fixing MySQL 10061 For Remote Connections
Remote MySQL connections introduce more moving parts: server configuration, system firewall, network gateways, and user access rules. The steps below help you track down which layer rejects the request.
- Test basic reachability of the host — From your client machine, ping the database server host or use
tracert/tracerouteto confirm the host is up and reachable. - Probe the MySQL port from the client — Use
telnet server_ip 3306ornc -vz server_ip 3306. If you see a MySQL greeting, the port is open; if the tool shows a refused connection, something is blocking or no service listens. - Relax an overly strict bind address — On the server, open
my.cnformy.iniand adjustbind-address. To allow remote access, set it to0.0.0.0or to the specific interface address, then restart MySQL. - Confirm no skip-networking flag is set — Remove
skip-networkingfrom the configuration or disable it if present, so MySQL accepts TCP connections on its port. - Update firewall rules for TCP 3306 — On the database host, add an inbound rule that allows TCP traffic to the MySQL port from your application servers or trusted IP ranges.
- Grant user access from remote hosts — Log into MySQL locally and create or adjust a user with a host that matches remote clients, such as
'appuser'@'app_server_ip'or a controlled wildcard like'appuser'@'%'. - Restart MySQL and retest — After configuration and firewall changes, restart the MySQL service and run your remote connection test again from the same client that saw this error.
If the remote check still throws error 10061 while local connections work, the port test usually reveals whether the problem sits in MySQL itself or in a firewall or network rule in front of it.
MySQL 10061 Connection Refused On Managed Hosting
On managed servers and shared hosting, this 10061 connection error often reflects provider policies rather than mistakes on your side. Many hosts allow database access only from web applications on the same platform and block direct port 3306 access from the public internet.
- Check host documentation for remote MySQL rules — Many hosts require you to register your IP address or use an SSH tunnel for remote MySQL access.
- Use control panel tools — Panels such as Plesk or cPanel often include a MySQL section where you can enable remote access, create users, and list allowed client addresses.
- Try an SSH tunnel when ports stay closed — Forward local port 3306 through SSH to the MySQL host so the database keeps listening only on localhost while you reach it through the tunnel.
- Ask the provider about blocked ports — If your port checks always show a refused connection and configuration looks correct, open a ticket and share the exact 10061 message and host details.
In these hosting setups you often cannot change the main MySQL configuration file, so success depends on aligning with the provider’s connection rules instead of forcing your own layout.
How To Prevent MySQL 10061 Long Term
Once MySQL Error 10061 is fixed, a few simple habits can make it far less common across your projects. These ideas work for both local development and production servers.
- Keep MySQL running as a managed service — Configure MySQL or your stack to start with the operating system, and use service management rather than manual command prompts.
- Document host, port, and user details — Store connection settings in a safe configuration store so new tools and team members use consistent values.
- Plan firewall rules with the database in mind — When you add new servers or security groups, include rules that let trusted application hosts reach MySQL directly.
- Test after configuration edits — After you change
my.cnf, update SSL settings, or switch ports, run a quick command line connection from both the local host and a remote client. - Use different ports only when needed — If you move MySQL away from 3306, keep a short note near any connection string so people know which port to use.
These habits reduce surprise outages where nobody remembers which setting changed shortly before this error code appeared on every client.
When MySQL 10061 Still Appears After Fixes
Now and then the error persists even after service restarts, configuration tweaks, and firewall updates. At that point it helps to widen the checks beyond the database itself.
- Look for another service using the port — Run a process listing for port 3306 to make sure no other program is sitting on the port that MySQL should use.
- Check container or VM port mappings — In Docker or virtual machines, confirm that the internal MySQL port is mapped correctly to the host port and that the host address matches your connection string.
- Test from a different client host — Run the same connection test from another machine to see whether the refusal is tied to a single workstation or affects all clients.
- Use simple command line tools first — Before you debug complex libraries or ORMs, try a plain
mysqlcommand from the same host with the same credentials and port. - Collect logs and exact messages — Save the MySQL error log, client stack traces, and firewall logs. When you ask an experienced DBA or hosting engineer for help, these details speed up the investigation.
Once these outer layers check out and MySQL still returns error 10061 again, a close reading of the server log around startup and connection attempts usually reveals the final missing detail, such as a wrong interface, a reused port, or a network policy that still refuses the TCP handshake.
