Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

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'm trying to connect to my database via SSH tunneling from one of our web app servers with MySQL Workbench. Here's the basic config; note that I changed some values in the screenshot for security reasons.

Workbench screenshot

The problem is every time I try to connect over an SSH tunnel from one of our app servers, I get the following error:

Failed to connect to through SSH tunnel at with user social_shop_prod. Can't connect to MySQL server on

However, if I use the same credentials over SSH via the following command line:

mysql -u social_shop_prod -h -p

I can connect successfully and get the MySQL interactive command prompt.

Been talking with the rest of my development team here and none of us can figure out why I can't tunnel over SSH from our app servers with Workbench; but when I SSH to one of our app servers and connect to MySQL via the command line; I can connect successfully.

And why is it trying to connect over I didn't specify that in the configuration; nor is my hosts file redirecting the domains shown below to that IP.

Any constructive input is greatly appreciated.

share|improve this question

Since you are connecting through a SSH tunnel, this means that the MySQL port 3306 from is being opened locally on your computer. The ip address of your computer is or localhost. When you connect to the mysql server on, you're actually accessing it via, i.e. your computer. If you had another tunnel open, or MySQL running locally on your computer, then it may be that other MySQL server that's rejecting your authentication attempts

There are some tests you can try :

1. What ports is you Windows computer listening on

From a command prompt : netstat -a (lists all the ports that are open)

In linux it would be : netstat -tlpn

2. Basic connectivity test

From a DOS command prompt or linux console : telnet 3306

If you get a time out, or some other program responds then your tunnel isn't setup correctly.

3. Change the port number that MySQL Workbench is opening locally

We're assuming that MySQL workbench is creating the tunnel on your computer. If so, in MySQL workbench, try tunneling through another port number like 9000.

Make sure that 9000 wasn't listed as an open port from : netstat -a

If you have ssh access to

4. Try connecting to MySQL from

mysql -u myuser -h -p

And as Rolando said, you'll want to verify that you are connecting with the right credentials. For example, if you are connecting as myuser@ and you have a user myuser without a host, you probably won't be able to connect using user@

share|improve this answer

The reason that is being contacted is because the tunnel connects a port on your local machine to the remote host. The message seems to suggest that an SSH connection is not being made.

Try this from the command line:

ssh -L 33000:remotehost:3306 user@remotehost

Make sure that SSH is allowing forwarded ports; if you get a message that states the forward was not permitted or was refused, then that is why.

To fix this, you'd have to change the server configuration; add this configuration to the SSH server:

AllowTcpForwarding yes

Don't forget to restart the server to activate this configuration.

share|improve this answer
can you explain that command a bit? you're binding the address? Can that be combined with mysql commands? – Thufir Feb 23 '15 at 12:33
With SSH here you are setting up a tunnel, nothing more. It connects a remote port to a local port. What you do in this case is tie a local port to the remote MySQL port. – Mei Feb 23 '15 at 15:48

In my case the issue I had to switch back to a valid domain name or IP instead of a custom host locally host resolved.

Custom host resolution fail (/etc/hosts)

I work with a local hosts resolution mechanism which defined:

#.#.#.#    my-vm

For some reason with MySQL 5.2.47 on Linux Mint 14 (Nadia) which is similar to Ubuntu 12.10 (Quantal) the resolution mechanism doesn't work.


Simply switch to a public domain name such as solve the issue.

share|improve this answer
@Mat fixed, thanj=ks – Édouard Lopez Sep 23 '13 at 15:17

See here for a list of resources for connecting to various targets (Amazon RDS, Amazon EC2, Windows Azure and others):,252640,252640#msg-252640.

share|improve this answer

I had a similar problem, and this may be obvisous, but check you firewall rules in AWS. I have an IP range set, to restrict connections from the outside world. And the IP at my office changed, so it got outside the IP range. My colleague in another ofice could still connect, so I thought the problem is on my PC, but the problem was with the firewall rules in AWS. Hope that helps someone :)

share|improve this answer

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.