I am trying to connect to MySQL from my MySQL GUI (Sequel Pro if it matters) using SSH tunnel. However, I keep getting the following error (mysql.log):

[Note] Aborted connection 98 to db: 'example' user: 'example_user' host: 'localhost' (Got an error reading communication packets)

My connection settings look like the following:

  • SSH host: example.com
  • SSH port: 22
  • SSH user: example_user
  • SSH pass: ********
  • DB host:
  • DB user: example_user
  • DB password: *******
  • DB name: example
  • DB port: 3306

I can connect to SSH with no problems. I can also connect to MySQL from inside SSH (using mysql -u example_user -p -h

However, tunneling is not working. I have AllowTcpForwarding yes in sshd_config. MySQL config has bind-address =

I am using 16.04 LTS and MySQL Community Edition in my server.

What am I doing wrong? This is the first time I am seeing this issue.

  • 1
    What are you using to create the SSH tunnel? – Tero Kilkanen Mar 19 '17 at 16:20
  • Possible duplicate of What causes the 'Connection Refused' message? – user9517 Mar 19 '17 at 17:51
  • I am using the Sequel Pro client. That client currently connects to 3 different remote hosts via SSH tunnel. This is the only host where this doesn't work, so I my guess is it is a problem in the host machine. – Gasim Mar 19 '17 at 18:12
  • @istheEnglishway MySQL is listening on I have UFW disabled and iptables is empty with default ACCEPT. One thing that I am having doubts here is the SSH server used in Ubuntu. It is called OpenBSD Secure Shell server. I have always used OpenSSH server and never had a single issue with it. Can this server not have a TCP forwarding feature? I am asking this because AllowTcpForwarding option did not exist in sshd_config. I added it myself with no luck – Gasim Mar 19 '17 at 18:21
  • Nevermind, OpenBSD Secure Shell is the long name for OpenSSH. – Gasim Mar 19 '17 at 18:24

You can create several tunnels via command on workstation by example:

ssh -L 10080: -L 10006: user@server

There are: - ip-address tunnel's destination to connect from server, 80 and 3306 destination ports, 10080 and 10006 - local workstation's ports. This will allow you to connect to MySql server and to Http server via server's localhost interface. Run command mysql -p -u db_user -P 10006 -h database_name on workstation to connect to MySql server. You can connect to PhpMyAdmin web interface, which is allowed only from To do it simply write address in your browser.

  • 1
    For some reason tunelling like that actually works but tunelling through my mysql application doesn't work, which is very weird IMO. – Gasim Mar 21 '17 at 13:16
  • @Gasim Try to use "Standard connection" to host and port 10006. – Mikhail Khirgiy Mar 21 '17 at 13:23
  • Also check how well will a long file (500Mb) be copied from server to workstation via scp command? – Mikhail Khirgiy Mar 21 '17 at 13:31
  • staandard connection worked. I just didn't want to have a separate tunnel open when my app can do it. I'm going to investigate to see what can cause this problem. – Gasim Mar 21 '17 at 15:17
  • I think you can use sshd log on the server as described at serverfault.com/questions/130482/how-to-check-sshd-log – Mikhail Khirgiy Mar 21 '17 at 15:45

I had a similar issue, and per this answer, the solution was removing the 'any' user.

It seems that MySQL sees a difference between a user connecting via localhost and, which is part of the issue if I understand it correctly.

  • 1
    MySQL's authentication layer is not going to cause a connection refused message. – womble May 9 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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