Bootstrap FreeKB - mySQL / MariaDB - Resolve "ERROR 2003 (HY000) Cant connect to MySQL server (110)" (connection timed out)
mySQL / MariaDB - Resolve "ERROR 2003 (HY000) Cant connect to MySQL server (110)" (connection timed out)

Updated:   |  mySQL / MariaDB articles

Let's say the following is displayed when attempting to connect to mySQL or MariaDB.

ERROR 2003 (HY000): Can't connect to MySQL server on '' (110)


The most relevant part of this error message is (110), the error code.

The perror command line tool can be used to determine what the error code represents.

~]# perror 110
OS error code 110:  Connection timed out


Is mySQL / MariaDB running?

If you have access to the mySQL or MariaDB system, and mySQL or MariaDB is running on a Linux system, the systemctl or service command can be used to see if mySQL or MariaDB is up and running.

~]# systemctl status mysql
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-12-21 16:08:26 CST; 2 weeks 1 days ago
     Docs: man:mysqld(8)
  Process: 1416 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1650 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─1650 /usr/sbin/mysqld

Dec 21 16:08:22 systemd[1]: Starting MySQL Server...
Dec 21 16:08:26 systemd[1]: Started MySQL Server.



Notice in this example that the hostname of the mySQL or MariaDB system is The nslookup command can be used to ensure DNS is able to resolve the hostname to the IP address of the server running mqSQL or MariaDB.

~]$ nslookup



Port 3306 & Firewall

Notice in this example that the port being used is 3306, which is the default port used by mySQL and MariaDB. Refer to mySQL or MariaDB port to determine the port being used. If you have a firewall in front of your MariaDB system, such as firewalld, you will need to ensure the port is open/allowed in the firewall.

firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload


localhost vs. % (remote) connections

Users are allowed to connection to mySQL or MariaDB via locahost or remote.

  • localhost means that the user is making the connection on the system that contains the mySQL or MariaDB service (in other words, the actual mySQL or MariaDB server).
  • % (remote) means that the user is making the connection from some other system.

If you have access to the system running mySQL or MariaDB, and you have been granted the select permission, you can determine if a user is allowed to make a localhost connection, a remote connection, or both.

~]# mysql --execute="select Host,User from mysql.user \G"
*************************** 1. row ***************************
Host: localhost
User: root
*************************** 2. row ***************************
Host: %
User: root
*************************** 3. row ***************************
Host: %
User: john.doe


General Log and Error Log

The general log and error log may have events that correlate to the failed connection. This command can be used to determine if the logs are enabled and the location of each log.

~]# mysql --execute="show variables" | egrep -ie 'general_log|log_error'
general_log       OFF
general_log_file  /var/log/mysql_general.log
log_error         /var/log/mysqld.log


The /etc/my.cnf or /etc/my.cnf.d/mariadb-server.cnf file should contain the log-error directive. In this example, MariaDB is configured to log errors to the /var/log/mariadb/mariadb.log file. Check the error log to see if there are any events that correlate to the failed connection.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter a6028a in the box below so that we can be sure you are a human.