I'm trying to connect to port 3306 on an Ubuntu box and am unable to do so. When I do iptables -L -n | grep 3306
I see this:
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:3306
So it looks like I should be able to connect.
Are there any rules that I should look for that could undo these? In my cursory glance I didn't see any. Plus, when I do grep 80
and grep 443
I see pretty much the same thing as above, but with 80 and 443 instead of 3306. And I'm able to connect on ports 80 and 443 even tho I'm not able to connect on port 3306.
The webserver is hosted on Rackspace's cloud. I know AWS has additional firewall rules independent of the OS that can be set - does Rackspace? I wasn't able to find any in going through the menu and my Google searches haven't proven very fruitful either.
In general, you should consider 1) MySQL bind-address, and 2) the firewall.
Since you aren't able to make a connection with
telnet SERVER_IP 3306
, either the firewall is blocking the connection or MySQL is not listening on that port.Firewall
You should review your firewall rules as a set, without piping to grep, to see if there are any matching rules above the one you pasted in your question.
On the topic of your firewall, it's generally a BadIdea™ to open :3306 to the public internet. I prefer to use an SSH tunnel to connect to my remote databases.
MySQL bind-address
Either look for "bind_address" in your MySQL config, or try
netstat -plnt
and look for MySQL in the list. To accept remote connections, bind_address must be something other than "127.0.0.1" (SSH tunnels work around this!).My solution was to reinstall ufw.
Then add port 3306.
with me i do not use ipbles though is a system manager you need to know but have to be very careful how about using a firewall ufw . if you already have that i will recommend you uninstall the fire wall:
sudo apt-get ufw remove
then restart your sever and clear all existing iptables. think itsiptables -
F** then reinstall ufw then open port 3306. **
sudo ufw allow 3306/protocol` that will open the port. if you can still connect with telnet then you need to check on your MySQL bind-address