Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

iptables

I am trying to connect to a remote mysql server but is encountering this error.On the server I have

  1. set bind-address to 0.0.0.0
  2. Changed Iptables to look like this

    target     prot opt source               destination 
    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3306
    ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:3306
    ACCEPT     tcp  --  107.22.*.*           0.0.0.0/0            tcp dpt:3306
    

    where 107.22.** is the IP of the machine I am trying to connect from

  3. Restarted UFW

  4. verified that my AWS security groups allow port 3306 is allowed access from everywhere.

What could be the reason for the error?

like image 657
Rishin S Babu Avatar asked Jan 14 '14 09:01

Rishin S Babu


1 Answers

Change iptables to look like this instead:

target     prot opt source               destination 
ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:3306
ACCEPT     tcp  --  107.22.*.*           0.0.0.0/0            tcp dpt:3306
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3306

Otherwise, all 3306 traffic gets dropped by the firewall.

like image 110
Ja͢ck Avatar answered Oct 02 '22 07:10

Ja͢ck