Page 1 of 1

can't connect to mysql server remotely

Posted: 15. May 2014, 00:46
by behelit
Hello all,

I've got a guest running Fedora 20, and I installed mysql on it. mysql is running on the guest and port forwarding appears to be setup correctly. I know it's working correctly because of this:

$ nc -z -w1 10.181.178.157 3306
Connection to 10.181.178.157 3306 port [tcp/mysql] succeeded!

$ echo X | telnet -e X 10.181.178.157 3306
Telnet escape character is 'X'.
Trying 10.181.178.157...
Connected to 10.181.178.157 (10.181.178.157).
Escape character is 'X'.

telnet> Connection closed.

However, when I actually try to connect to the mysql server using a client, I get this:

$ mysql -h 10.181.178.157 -uXXX
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Has anyone encountered this before? I've been pulling my hair out all day trying to get this to work.

Re: can't connect to mysql server remotely

Posted: 15. May 2014, 09:13
by unpunk
Similar issue here.

Host: Win7
Connection type: Network Address Translation Service (experimental)

Case 1:
Bitnami Redmine on Guest sometimes break connection on GET css and javascript files.

Case 2:
Guest: Ubuntu 14.04 LTS

Running "hg serve" in guest NAT is accessible by web, but rejects cloning:
pastebin. com/HyL7KHSU — external call (sorry for ugly link, I'm "must be a member for 1 days and have 1 posts before you can post urls.")
pastebin. com/bGUY5CQA — hg server log

Re: can't connect to mysql server remotely

Posted: 15. May 2014, 10:13
by noteirak
@unpunk : your topic is not about mysql, so please start your own topic and read Minimum information needed for assistance before doing so.

Re: can't connect to mysql server remotely

Posted: 15. May 2014, 10:18
by noteirak
behelit wrote:I know it's working correctly because of this:

$ nc -z -w1 10.181.178.157 3306
Connection to 10.181.178.157 3306 port [tcp/mysql] succeeded!

$ echo X | telnet -e X 10.181.178.157 3306
Telnet escape character is 'X'.
Trying 10.181.178.157...
Connected to 10.181.178.157 (10.181.178.157).
Escape character is 'X'.

telnet> Connection closed.
This actually doesn't prove anything except that the port on the host is open, it doesn't mean you actually reach something behind in the guest.
From your post, you are using NAT or NAT network, which will bind the port on the host, but will try at runtime to reach the port in the guest. It might or might not be open.
If it is open, you will get a successful connection, else the connection will be closed.

You are in the 2nd case scenario : Virtualbox binded the port on the host, but fails to connect to the guest port because it is not open. The connection then gets closed directly as you connect.
You can see this clearly in the telnet output - "Connection closed."
behelit wrote:However, when I actually try to connect to the mysql server using a client, I get this:
$ mysql -h 10.181.178.157 -uXXX
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Now that you are using the real client that will validate the protocol, you do get an error, since the connection gets closed directly without any data sent to the client.
This explains the error: the client is expecting a first comm packet from the server, but nothing is sent, and the connection is closed, so the client fails.

To put it into easier word : mysql is not listening on the IP & port you are using, and is most likely only listening on localhost. Fix this in the guest, and it should work.

Re: can't connect to mysql server remotely

Posted: 19. May 2014, 13:23
by vbox-usr
As noticed from my experience.
When using "Network Address Translation Service (experimental)", gateway goes down on heavy loads.
My example:
I have "Network Address Translation Service (experimental)" network created: natw1 (192.167.15.0/24).
On Win7 guest machine I've setup connection:

Code: Select all

ip:  192.167.15.100
gw:  192.167.15.2
     192.167.15.1
dns: 8.8.8.8
When fetching files from CVS, I've spotted that both 15.1 and 15.2 go down for a couple of seconds.
Win7 also notifies me of "No internet access" situation, but after a couple of seconds, both 15.1 and 15.2 go up again.
Seems like a bug.

Re: can't connect to mysql server remotely

Posted: 19. May 2014, 13:33
by noteirak
How is this related to the issue of the topic?

Re: can't connect to mysql server remotely

Posted: 19. May 2014, 13:37
by vbox-usr
noteirak wrote:How is this related to the issue of the topic?
You may lose connection when using "Network Address Translation Service (experimental)". Maybe that's the case.
Sorry, if that will not help.