Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Error “cannot connect to mysql server (10060)” – Here’s how to fix it

by | Jan 23, 2019

I can’t access my MySQL database remotely, it’s throwing “cannot connect to mysql server (10060)” error. Please help.

That was a recent support ticket received at our Server Management Services department where we manage our customer servers.

Website owners usually face this error due to firewall restrictions, MySQL service downtime, and more.

Today, we’ll discuss the top 5 reasons for this error and how our Server Administrators fix them.

 

“Cannot connect to mysql server (10060)” error – Causes and Fixes

Customers usually receive this error when they try to access the MySQL server remotely.

Cannot connect to mysql server (10060)” error means that the connection established failed because the host connected has failed to respond in time.

Let’s now see the main reasons for this error and how our Server Experts fix them.

1) Service downtime

One of the common reasons for this error is MySQL service not running on the server. And, the reason for service downtime can be due to heavy traffic spikes, resource outages, DDoS attacks, and more.

 

How we fix?

So, our Support Engineers confirm whether the MySQL service is running in the server with the netstat command.

netstat -plan | grep :3306

 

If the service fails or doesn’t respond, we’ll kill the dead process and restart the service once again. In addition to that, we check the server logs to find the reason for the downtime and fix it permanently.

[Do you face intermittent MySQL downtime issues? Our experienced Server Administrators can fix this for you.]

 

2) MySQL configuration issues

By default, MySQL listens for connections only from localhost.

bind-address 127.0.0.1

 

So, if MySQL only supports local connections, users will receive “Cannot connect to mysql server (10060)” error when establishing a remote MySQL connection.

 

How we fix?

Firstly, our MySQL experts check the MySQL configuration file /etc/mysql/my.cnf and confirm that MySQL remote access is enabled.

If not, we change the value of bind-address to 0.0.0.0 in /etc/mysql/my.cnf to accept all connections.

bind-address 0.0.0.0

 

Alternatively, we comment the bind-address parameter to enable remote connections. Similarly, in some cases, we give the bind-address as the IP address of the server where MySQL service listens.

bind-address database-IP

 

Here, MySQL will only listen connections to the server’s IP. Most importantly, we restart the MySQL service to reflect the changes.

We always recommend taking the backup of this file before making any modifications. Because, a small typo error in this file can break your MySQL service.

[Do you want to enable Remote MySQL access on your server? Click here, one of our Server Admins can do this for you.]

 

3) Firewall restrictions

The next possible cause is MySQL port 3306 not opened in the server firewall. In other words, MySQL server can’t accept any connection from the outside world due to firewall.

 

How we fix?

In such cases, our Support Engineers temporarily disable the firewall to determine whether the firewall is the culprit. Later, we check the MySQL port from /etc/mysql/my.cnf and use the telnet command to check the external connectivity to MySQL port.

telnet xx.xx.xx.xx 3306

 

If any firewall rules interfere with connectivity, we set the firewall rules to allow connections on the MySQL port.

For example, if MySQL server runs on Windows, we whitelist the MySQL port from Start > Control Panel > System & Security > Windows Firewall > Exceptions > Add Port.

Similarly, in Ubuntu servers we open the MySQL port in UFW firewall using the below command.

ufw allow 3306

4) No privileges to the remote user

Similarly, this error can occur if the MySQL user doesn’t have enough privileges to remotely access the MySQL server.

In such cases, users will get an error “cannot connect to mysql server (10060)”.

 

How we fix?

Here, our Hosting Engineers grant the user proper privileges to remotely access the database. Most importantly, we whitelist the remote hostname or IP address.

GRANT ALL ON *.* to 'user'@'host_name' identified by 'Password';
FLUSH PRIVILEGES;

 

Because, if a user connects as root user from a different machine, MySQL server can easily identify whether it’s the root user in the local server or remote server.

For example in cPanel servers, we whitelist the remote host or IP address from cPanel > Databases > Remote MySQL .

[Worried about MySQL user permissions. One of our MySQL Experts can help you here.]

 

5) Wrong MySQL connection string

Last but not least, wrong connection string used to access the MySQL server remotely may lead to this error. A small typo in the MySQL server name, database name, username, port, etc. can block the connection to the MySQL server.

 

How we fix?

In such cases, our Support Experts get the MySQL connection string details from the client. After that, we configure an ODBC connection to the server. If that works, we compare the new string with the connection string. And, if any mismatch is noted, we’ll correct it immediately.

Conclusion

In short, error “cannot connect to mysql server (10060)” can happen due to firewall restrictions, MySQL configuration issues, MySQL service downtime, and more. Today, we’ve discussed the top 5 reasons for this error and how our Support Engineers fix them.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

2 Comments

  1. Deepanshu Suman

    I got this issue done.
    my firewall was not accepting port 3306.
    btw thanks I was in this issue from 1 day.

    Reply
    • Sijin George

      Hello Deepanshu,
      Happy to know that article helped you.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF