Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I’ve been fussing around with opening up 1 simple port on a dedicated linux server which is using “Linux Firewall” iptables.

I’ve added the port (3306) in the tables using Webmin and terminal but it still will not let me connect remotely.

I’ve restarted iptables many times and it still won’t work.

Here is the output of iptables -L

Please help.

share|improve this question
Your firewall config (as posted at pastie) doesn't DROP or REJECT anything, so it doesn't do anything. It's a list of ACCEPTS, with a default of ACCEPT. Your MySQL server is misconfigured. – Bill Weiss Nov 17 '09 at 16:34
You might as well iptables -F, your firewall rules are allowing everything already. – Kyle Smith Nov 17 '09 at 17:30

I'll bet your MySQL instance isn't listening on the public IP, only on localhost or the Unix socket. Check the output of netstat -ltn for a local address ending in :3306; if there is none, it's listening on the socket, remove skip-networking from my.cnf and restart; if it says then it's listening on localhost, remove bind-address = from my.cnf and restart.

For security, it's best to access MySQL over an SSH tunnel, because MySQL doesn't encrypt anything and opening your MySQL instance to the world is a terrible idea anyway. This KB article from my work describes the process:

(Oh, and as an aside, that firewall isn't blocking anything anyway, as all your policies are set to ACCEPT. It's a firewall without a purpose).

share|improve this answer
My MySQL connection is listening on the correct address. I would do an SSH tunnel but I need a remote website to be able to connect to the database. – Frankie Laguna Nov 17 '09 at 16:09
netstat -ltn please. – womble Nov 17 '09 at 16:09

Mysql connection problem ?

I know it is sound weird but I have to ask is mysql running ?

in your my.cnf you might have the line skip-networking that block remote connection.

Also check the Daemon that starts your mysql in rc.mysqld (location might vary could be /etc/sysconfig/mysqld) doesn't have --skip-networking

on your mysql you could check with a :

mysql> SHOW VARIABLES LIKE 'skip_networking';

For iptables I do use:

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d [Server_IP] --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT-p tcp -s [Server_IP] --sport 3306 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

share|improve this answer
Skip networking is off, used the commands you posted and it still didn't work. Turned off iptables, and it still isn't working. So I used netcat to open 3306, and it still won't connect, so somehow with no firewall turned on it is still refusing connections. FTP, SFTP, SSH, Apache, all work fine. – Frankie Laguna Nov 17 '09 at 21:18

Do you have selinux running in enforcing mode ? Try cat /selinux/enforce to find out - I think the default enforcing mode will block incoming connections.

share|improve this answer
selinux wasn't found on this system. – Frankie Laguna Nov 17 '09 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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