MySQL Workbench may sometimes fail to connect to a MySQL Server running on your Windows PC. You may see errors such as Unable to connect to localhost, Can’t connect to MySQL server on ‘localhost’, or Error 10061: No connection could be made because the target machine actively refused it. In this post, we will see what you can do if you are unable to connect to localhost in MySQL Workbench.

Unable to connect to localhost MySQL Workbench
This usually happens when the MySQL Server service isn’t running, MySQL is listening on a different port, or Workbench uses connection settings that don’t match the server configuration. If you can’t connect to localhost in MySQL Workbench, follow the solutions below.
- Start the MySQL Server service
- Check whether MYSQL is listening on port 3306
- Check your port
- Use 127.0.0.1 instead of localhost
Let us talk about them in detail.
1] Start the MySQL Server service

MySQL Workbench is only a client application. It cannot connect to a local database if the MySQL Server service is stopped. You can check the service from Windows Services.
- Press Win + R, type services.msc, and press Enter.
- Scroll down and look for MySQL80 or another MySQL service installed on your PC.
- If the service is stopped, right-click it and select Start.
- Open MySQL Workbench and try connecting again.
If you cannot find a MySQL service, MySQL Server may not have installed correctly, or you may be using another package, such as XAMPP, that manages its own MySQL/MariaDB service.
You can also start the service from an elevated Command Prompt. First, find its name using the following command.
sc query type= service state= all | findstr /I "mysql"
Then start the service using its actual name. For example, net start MySQL80.
Finally, check if the issue is resolved.
2] Check whether MySQL is listening on port 3306

If the MySQL service is running but Workbench still cannot connect, check whether the server is actually listening for connections. You need to open Command Prompt as an administrator and run the following command.
netstat -ano | findstr :3306
Look for an entry containing LISTENING, such as TCP 127.0.0.1:3306 0.0.0.0:0 LISTENING
If you do not see anything listening on port 3306, MySQL may be configured to use another port, or the server may not have started correctly. This is especially useful because it tells you whether a server is actually waiting for Workbench’s connection.
3] Check your port
If the Listener is fine but you still see this issue, don’t assume the port is always 3306. If you installed MySQL alongside another development environment such as XAMPP, WampServer, or Laragon, a port conflict may have caused one of the servers to use a different port.
So, you need to find the MySQL configuration file, usually named my.ini, and look for the [mysqld] section:
[mysqld] port=3306
If the configuration contains another value, such as port=3307, use that port in MySQL Workbench.
For example: Hostname: 127.0.0.1 Port: 3307
After changing the configuration, restart the MySQL service before testing the connection again.
We also need to look at other reasons for a port conflict. So, open Command Prompt and run the following command.
netstat -ano | findstr :3306
You may see something similar to:
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 4520
The last number is the PID of the process using the port.
You can identify it with:
tasklist /FI "PID eq 4520"
Replace 4520 with the PID shown on your PC.
If another MySQL installation is using the port, you may have multiple MySQL services installed on Windows. Make sure you start and connect to the intended MySQL Server instance. Do not randomly terminate the process just because it is using port 3306. First, determine what application it belongs to.
4] Use 127.0.0.1 instead of localhost

If MySQL is running and listening on the expected port, try changing the hostname in Workbench. Open your MySQL Workbench connection and set it as follows.
Hostname: 127.0.0.1 Port: 3306
Instead of:
Hostname: localhost Port: 3306
Then click Test Connection.
This helps when localhost resolves to an address that doesn’t match the address the MySQL Server is listening on. MySQL Workbench lets you specify the server hostname and TCP/IP port directly in the connection configuration.
That’s it!
Read: WSL Localhost connection refused on Windows computer
Why can’t I connect to localhost in MySQL?
You may be unable to connect because the MySQL Server service is stopped, the server is using a different port, or MySQL Workbench has incorrect connection settings. On Windows, check the MySQL service in services.msc, then verify that MySQL is listening on port 3306. You can also try 127.0.0.1 instead of localhost and test the connection from Command Prompt.
Read: Localhost refused to connect in Chrome on Windows 11
Why isn’t my MySQL server running on localhost?
Your MySQL Server may not be running because its Windows service failed to start, another application is using its configured port, or the MySQL configuration contains an error. Open services.msc and check the MySQL service status. If it stops immediately after starting, check the MySQL error log for details. You can also run netstat -ano | findstr :3306 to check for port conflicts.
Also Read: Deployment Workbench crashes when opening WinPE Properties.