I have an AZURE virtual machine with a MySQL server installed on it running ubuntu 13.04. I am trying to remote connect to the MySQL server however get the simple error "Can't connect to MySQL server on {IP}"

I have already done the follow:

* commented out the bind-address within the /etc/mysql/my.cnf
* commented out skip-external-locking within the same my.cnf
* "ufw allow mysql"
* "iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT"
* setup an AZURE endpoint for mysql
* "sudo netstat -lpn | grep 3306" does indeed show mysql LISTENING
* "GRANT ALL ON *.* TO [email protected]'%' IDENTIFIED BY 'password';
* "GRANT ALL ON *.* TO [email protected]'localhost' IDENTIFIED BY 'password';
* "/etc/init.d/mysql restart"
* I can connect via SSH tunneling, but not without it
* I have spun up an identical ubuntu 13.04 server on rackspace and SUCCESSFULLY connected using the same procedures outlined here.

NONE of the above works on my azure server however. I thought the creation of an endpoint would work, but no luck. Any help please? Is there something I'm missing entirely?

enter image description here

  • What is the error you receive when connecting to the MySQL server? – Michael Hampton Oct 31 '13 at 0:21
  • ERROR 2003 (HY000): Can't connect to MySQL server on 'IP' (60) – Rees Oct 31 '13 at 1:01
  • Try disabling Direct Server return. – proteus Apr 10 '14 at 19:44
  • Here is official manual for Azure VM: manual – Nikolay Bronskiy Feb 23 '15 at 0:57

The 'official manual' quoted above didnt work for me and seems to set up a ssh tunnel to accomplish this... even after following the guide it still didnt work.

Heres my working solution

For a Ubuntu Azure VM see:


Specifically the section "Allow remote access to MySQL"

Comment out:

 bind-address = 

located at /etc/mysql/my.cnf


 sudo service mysql restart

and my remote connections worked --- just make sure port 3306 is open in the azure server portal for your vm!

| | |
  • I had to reboot my Azure machine before I could get the port opened. I'm not sure if it was a problem with the Azure firewall or with mariadb not wanting to read the config file on reboot. – Loren Apr 6 '17 at 20:56
  • In my vm, this line was in /etc/mysql/mysql.conf.d/mysql.cnf file. – zinon Feb 7 '19 at 10:19

This succinct guide was useful for me to get mine to work.

While there are other essential steps [that I had already done] there, the one I was missing was this:

3306 port is not opened by default, hence you need to first open this port so a remote client can connect to your MySQL Server. Run the following command to open TCP port 3306:

iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

check if the port 3306 is open by running this command:

sudo netstat -anltp|grep :3306
| | |
New contributor
Matthew Kooshad is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Check your firewall uring sudo ufw status.

| | |

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