SQL Error(2013) Lost Connection: reading initial communication packet

stugol posted 5 years ago in Creating a connection
Hi, I am able to connect to mysql on Hostgator over TCP, which works great but ssh has caused the following error:

SQL Error (2013): Lost connection to MySQL server at 'reading inital communication packet', system error:0

I used putty and is ablke to connect to ssh and mysql without problems using the same credentials as below:

Network type: MySQL (SSH Tunnel)
User: mysql_user
Password: mysql_password
Port: 3306
Database: mysql_database

SSH Tunnel:
plink location: plink_location
ssh host: ssh_ip
ssh port: 2222
user: ssh_user
password: shh_password
local port: 3307

Any help is much appreciated.

stugol posted 5 years ago
Anyone? Thanks in advance.
ansgar posted 5 years ago
Probably too slow connection. Or something in the SSH server which does not work as expected. Well, just guesses here. It's very difficult to debug these tunnel connections.
stugol posted 5 years ago
Thanks anse, probably not too slow as I could putty in manually. Thanks a million, the program rocks but too bad can't tunnel at this time.
ansgar posted 5 years ago
At least the error message "reading inital communication packet" tells me your tunnel works, as you already touch the mysql server. Well, that does not make it easier to debug :)
thadin posted 5 years ago
I had the same problem.

I was able to solve it to change the bind-address on the mysql server.
It was set to only listen to the remote ip address.
When I changed it to (all address, including localhost) it worked.
achbed posted 4 years ago
Note to self: When setting up SSH, you MUST set the following option in /etc/ssh/sshd_config:

AllowTcpForwarding yes

If you don't, then your packets will be silently dropped at the server. This results in the above error message.
davidshq posted 2 years ago
@achbed - This option is set by default to yes according to OpenSSH documentation? Just stumbled upon this thread as I am having this problem and trying to resolve.
MrBW posted 1 year ago

My solution was to change the "bind-address" IP in the MySQL config file "/etc/mysql/my.cnf". It was set to the local IP of the server instead of "" :-)

MrBW posted 1 year ago

My solution was to change the "bind-address" IP in the MySQL config file "/etc/mysql/my.cnf". It was set to the local IP of the server instead of "" :-)

I know I cannot connect directly to the server from outside. It seems I have to set the IP to "" and then use the firewall to restrict access if I want any.

Please login to leave a reply, or register at first.