Cannot Connect To Private Network MySQL

Posted August 30, 2018 3.4k views
MySQLUbuntu 16.04

2 droplets same data center, same project.
Both droplets are behind the same firewall.

I am attempt to connect from Droplet 1 to MySQL on Droplet 2
however, I keep getting:
“ERROR 2003 (HY000): Can’t connect to MySQL server on”

telnet 3306
telnet: Unable to connect to remote host: Connection refused

Telnet over port 22, 80, 443 is all fine.
I can ping ok.

I have set my mysql.cnf file to bind over
I have set up a user with the @ % for the sake of debugging the connection issue, but still no luck.
I restarted mysql
I flushed the privileges.

netstat -tulnp | grep mysql
tcp 0 0* LISTEN 23317/mysqld

What am I missing here?

Thank you!!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers

Hey friend!

I feel like the most likely cause here is firewall. Are you using our firewall or iptables/ufw/firewalld? If you’re using our firewall and have port 3306 open in it, try removing the firewall from the droplets just for kicks. Never hurts to rule it out. Otherwise, are you certain that the port is open in your firewall and above any other rule that might first reject the traffic?


the forum is rejecting my reply as spam, so putting this in the answer section to help share more information.

Both droplets (Ubuntu 16) are behind the DigitalOcean firewall, so that should not be blocking anything as they are connected to each other via private network. I did open port 3306 on the DigitalOcean firewall and it had no effect.

iptables are not enabled:
service iptables stop
Failed to stop iptables.service: Unit iptables.service not loaded.

I ran ufw allow mysql
No change in connecting.

I ran ufw disable on both droplets
ufw disable
Firewall stopped and disabled on system startup

At this point 3306 is an open port in the digitalocean firewall.
ufw is completely disabled on both boxes

yet I still get:
telnet 3306
telnet: Unable to connect to remote host: Connection refused

mysql -u username -p -h privateNetworkIP
Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xx.xx.xx.xx’ (111)

telnet 22
Connected to
Escape character is ’^]’.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4

telnet on port 80 also works, but ssl port 443 fails like 3306

DigitalOcean Firewall Settings:
Inbound Rules
Type Protocol Port Range Sources

SSH TCP 22 All IPv4 All IPv6
HTTP TCP 80 All IPv4 All IPv6
HTTPS TCP 443 All IPv4 All IPv6
MySQL TCP 3306 All IPv4 All IPv6

Outbound Rules
Set the Firewall rules for outbound traffic. Outbound traffic will only be allowed to the specified ports. All other traffic will be blocked.
Type Protocol Port Range Destinations

All TCP TCP All ports All IPv4 All IPv6
All UDP UDP All ports All IPv4 All IPv6

Any other ideas?

I appreciate the help on this!

@dpp777 did you ever find a solution to this? I’m in the exact same boat as you.