I am attempting to setup my home web server (Ubuntu Server 12.04) such that I can ssh to it from outside of my home network as well as connect to the MySQL databases that I have created on it.

Currently, I know that port 80 is responding correctly to requests. I have Apache running on it, so there are no problems there. However, when I try to SSH to the server, I do not get a response, nor do I get one when I connect to it on port 3306 via MySQL (ERROR 2003, Can't connect to server (10060)). I can use phpmyadmin to connect from my browser, but this is not useful for connecting via PHP.

I have port forwarding set up for ports 80, 22 and 3306, but I do not know what else I should do. Please forgive me if the answer is obvious/simple to obtain - I have been trying to fix this for months.


The output of netstat -atn | grep [port] for ports 22 and 3306 are as follows:


tcp    0    0 0.0.0:22 *          Listen
tcp    0    0    Established 
tcp    0    0    Established 
tcp6   0    0 :::22              :::*               Listen


tcp    0    0 0.0.0:3306 *          Listen

Thank you.

  • Also, I do not believe that this issue is too localized. I have seen many posts about this issue around the Internet, but most were not solved.
    – nmagerko
    Jul 11, 2013 at 20:30
  • Lots of possibilities - misconfigured port forwarding, blocked ports by your ISP, etc. There's nothing odd that phpmyadmin works - once you've connected to it at port 80, everything else is happening locally on the web server/intranet, so it doesn't need ports to the outside world . . .
    – ernie
    Jul 11, 2013 at 20:33
  • What type of firewall are you using?
    – Jim G.
    Jul 11, 2013 at 20:33
  • Well @ernie if there's anything that I can provide that would help you to help me solve this, I would appreciate if you would let me know... I am only using the default ufw, Jim G
    – nmagerko
    Jul 11, 2013 at 20:35
  • 2
    Seeing how you've configured your port forwarding, as well as a port scan of the outside address (e.g. grc.com/shieldsup‎, canyouseeme.org, etc) would be useful. Obviously verifying you can connect to the services via the intranet would also help.
    – ernie
    Jul 11, 2013 at 20:38

3 Answers 3


SSH - Make sure that you install the SSH Server

sudo apt-get install openssh-server

MYSQL - Make sure that you allow outside connections

sudo nano /etc/mysql/my.cnf

Comment out bind-address if you want to grant access to outside connections.

You will need to make sure that the user that you are connecting to MySQL has access from outside of the localhost address.

  • Unfortunately, all of this has already been done. I've had the ssh server for a while, and the bind address is commented out. All users have both local and % access to the server. It would seem that the problem is that the requests are not going "through" the ports
    – nmagerko
    Jul 11, 2013 at 20:42

Check your router's firewall settings and make sure that ports 22, 80 and 3306 are open.

Port-forwarding often doesn't automatically open the ports on your router's firewall - I realise that it seems silly and trivial, but I was bitten by this bug on one of my previous home routers (Orange UK's LiveBox).

  • I will certainly check this out now
    – nmagerko
    Jul 11, 2013 at 20:55
  • I disabled the firewall completely, but apparently nothing changed :/ Very good suggestion though
    – nmagerko
    Jul 11, 2013 at 20:59

Wow UFW does a lovely mess of iptables, It looks to me that ssh is not unblocked on the firewall use

sudo ufw status

to see whats allowed or blocked and try

sudo ufw allow ssh

i found a nice guide here http://blog.bodhizazen.net/linux/firewall-ubuntu-servers/ which you might take a look at, alternatively i use the old tried and tested method of generating a bash iptables script (from http://www.mista.nu/iptables/) and run it at boot from rc.local.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .