I have a MySQL server instance installed on an Ubuntu machine. I have ensured that it is listening on port 3306. I have set the bind address to I have checked that there is no firewall. I am attempting to login with a user that is allowed to connect from any address (user was created with 'user-name'@'%'.

I am attempting to connect using MySQL Workbench running on a Windows machine.

The error message says "Unable to connect to localhost", even though the connection profile is using TCP/IP method and has the server IP address and port number specified.

I've looked over a bunch of various questions on this topic and none of them have addressed my issue. I feel like I'm probably missing something basic, but I just can't figure it out.

-edit- In response to mustaccio's comment, here is how I'm checking thigns:

the result of sudo netstat -tunlp is

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0  *               LISTEN      219757/nrpe
tcp        0      0 *               LISTEN      1422415/mysqld
tcp        0      0  *               LISTEN      1422415/mysqld

for bind address, The relevent portion of the /etc/mysql/mysql.conf.d/mysqld.cnf file is

# * Basic Settings
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
 socket = /var/run/mysqld/mysqld.sock
 port           = 3306
# datadir       = /var/lib/mysql

# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir                = /tmp
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            =
mysqlx-bind-address     =

for firewall, sudo ufw status verbose results in Status: inactive

for the username, the user and host parameters in the mysql.user table is 'user-name' and '%', as verified by

use mysql;
select user, host from user;

Not sure what better proof I can provide

  • 1
    Based on what you report, everything should work just fine. Since it obviously does not, what you report does not reflect the actual facts. You didn't provide any details that would help anyone diagnose the problem, therefore it is unlikely that you will get a meaningful answer to your post.
    – mustaccio
    Jun 7, 2022 at 18:49
  • @mustaccio I've edited to add the proof and how I arrived at believing those things to be true. I'm not sure what additional details would be helpful, but I'm happy to provide them if there's something specific.
    – C. Denney
    Jun 7, 2022 at 20:36
  • The problem is clearly on the client, which for some reason is trying to connect to localhost, so server settings are not very relevant.
    – mustaccio
    Jun 7, 2022 at 20:46
  • The connection settings in the MySQL workbench are as follows: Connection method: Standard (TCP/IP) Hostname: (IP address of the server) Port: 3306 username: user-name Those are all the default settings of the connection. not sure if there is anything else I need to set.
    – C. Denney
    Jun 7, 2022 at 20:49
  • @ErgestBasha The error log doesn't appear to show any rejected login attempts, so that does seem like a possibility, although I'm not sure why that would be (given the connection settings I just mentioned). nmap from the client machine is able to find the port on the server just fine, so the machine overall is able to reach it.
    – C. Denney
    Jun 7, 2022 at 20:50

1 Answer 1


I've just run into this issue myself. In my case, the version of the MySQL Server (5.1) is too old for MySQL Workbench (8.0) to connect to and results in the completely misleading error 'Unable to connect to localhost'

See https://dev.mysql.com/doc/workbench/en/wb-intro.html:

Deprecated versions of MySQL Server (prior to version 5.6) are incompatible with MySQL Workbench and should be upgraded before you attempt to make a connection.

Have downloaded the most recent version prior to 8.0 from the archives at https://downloads.mysql.com/archives/workbench/ (version 6.3) and this allows me to connect without issue (although I should get the server upgraded as soon as I can).

Not the answer you're looking for? Browse other questions tagged or ask your own question.