Fix: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘’ (111)

This tutorial is intended to explain the necessary steps for solving the “ERROR 2003 (HY000): Can’t connect to MySQL server on ‘’ (111)” which might occur when you try to access the MySQL database server.

Before moving any further, if you are a Linux user who is new to MySQL/MariaDB, then you may consider learning MySQL / MariaDB for Beginners – Part 1 and 20 MySQL (Mysqladmin) Commands for Database Administration in Linux as well.

On the other hand, if you are already a intermediate/experienced MySQL user, you can master these 15 Useful MySQL/MariaDB Performance Tuning and Optimization Tips.

Note: For this tutorial, it is assumed that you have already installed mysql database server.

Coming back to the point of focus, what are some of the possible causes of this error?

  1. Network failure especially if mysql database server is running on remote host.
  2. No mysql server is running on the mentioned host.
  3. Firewall blocking TCP-IP connection or other related reasons.

Below are the essential steps to deal with it.

1. If database server is on a remote machine, then try to test the client-server connectivity using ping command, for instance:

$ ping server_ip_address
Ping Host Machine
Ping Host Machine

Once there is connectivity, use the ps command below which shows information about a selection of the active processes, together with a pipe and grep command, to check that the mysql daemon is running on your system.

$ ps -Af | grep mysqld

where the option:

  1. -A – activates selection of all processes
  2. -f – enables full format listing
Check MySQL Process
Check MySQL Process

If there is no output from the previous command, start the mysql service as follows:

$ sudo systemctl start mysql.service
$ sudo systemctl start mariadb.service
# sudo /etc/init.d/mysqld start

After starting mysql service, try to access the database server:

$ mysql -u username -p -h host_address  

2. If you still get the same error, then determine the port (default is 3306) on which the mysql daemon is listening by running the netstat command.

$ netstat -lnp | grep mysql

where the options:

  1. -l – displays listening ports
  2. -n – enables display of numerical addresses
  3. -p – shows PID and name of the program owning the socket
Find MySQL Port Number
Find MySQL Port Number

Therefore use the -P option to specify the port you see from the output above while accessing the database server:

$ mysql -u username -p -h host_address -P port

3. If all the above commands run successfully, but you still see the error, open the mysql config file.

$ vi /etc/mysql/my.cnf
$ vi /etc/mysql/mysql.conf.d/mysqld.cnf 

Look for the line below and comment it out using the # character:

bind-address = 

Save the file and exit, afterwards restart the mysql service like so:

$ sudo systemctl start mysql.service
$ sudo systemctl start mariadb.service
# sudo /etc/init.d/mysqld start

However, if you have firewallD or Iptables running try to review firewall services and open the mysql port, assuming it is firewall blocking TCP-IP connections to your mysql server.

That’s all! Do you know other methods or have suggestions for solving the MySQL connection error above? Let us know by dropping a comment via the feedback form below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. Hi Aaron,

    Can you please contact me? I have a few questions about connecting the client to the DB_VM Instance.

    Please, it’s very important for me. I have to solve this problem.

    Thank you in advance.

  2. Thank you. This information was extremely useful. The problem in my case was the bind-address (which seems like a new default).

  3. PHP Warning: mysqli_connect(): (HY000/2003): Can’t connect to MySQL server on ‘’ (111)

    How to setup this error, while using GoDaddy shared hosting

    • @Ravi

      You need to contact the GoDaddy web/system admins. Normally, there are some access restrictions in shared hosting environments to backend configurations.

  4. I am trying to connect to my master server database, but getting the below error.

    [root@mysqlserver2 log]# mysql -u slave_user -p -h -P 3306
    Enter password:
    ERROR 2003 (HY000): Can't connect to MySQL server on '' (113)

    but I can able to access my master database with same credentials from the same server, When am trying from slave server getting that error.

    Please do help on this.

    Harikrishna Guggilla

    • @ Harikrishna

      Have you enabled remote root access on the master server. This could be the issue; try to run the mysql_secure_installation script and allow remote root access.

    • First of all, check your slave machine status: it is pinging or not?

      Then check your configuration file /etc/mysql/my.cnf or /etc/mysql/mysqld.conf/mysqld.cnf check your bind address.

      If the problem was not solved give grant privileges to the slave user from the master machine.

      that’s it.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.