how to understand "can't connect" mysql error messages?
Asked Answered
E

6

5

I have the following error message:

SQLSTATE[HY000] [2003] Can't connect to MySQL server on '192.168.50.45' (4)

How would I parse this (I have HY000, I have 2003 and I have the (4).

Ertha answered 27/6, 2012 at 16:43 Comment(7)
What do you mean by "I have HY000, I have 2003 and I have the (4)"Histolysis
Possibly answered here: #2139459Elmaleh
another possible solution: wolfcms.org/forum/topic1123.htmlOckham
@Elmaleh - over there it is code 111, I have code 4Ertha
@Histolysis see answer below, there are several codes in this error message. Which is exactly my question, how would I know which is which.Ertha
OS error code 4: Interrupted system call - at least as near as I can tell... Are you sure that your mysql installation is up and active, and accepting connections?Elmaleh
@Elmaleh - yep, pretty sure, as everything works fine, but once every few hours my error monitor catches this error message. b.t.w it is a backend process, not through apache/web serverErtha
C
10

HY000 is a very general ODBC-level error code, and 2003 is the MySQL-specific error code that means that the initial server connection failed. 4 is the error code from the failed OS-level call that the MySQL driver tried to make. (For example, on Linux you will see "(111)" when the connection was refused, because the connect() call failed with the ECONNREFUSED error code, which has a value of 111.)

Chloral answered 27/6, 2012 at 16:47 Comment(2)
Ok, so how would I know what 4 means? I am on UbuntuErtha
You wouldn't, unless you know exactly which system call is failing.Chloral
M
4

Using the perror tool that comes with MySQL:

shell> perror 4
OS error code   4:  Interrupted system call

It might a bug where incorrect error is reported, in this case, it might a simple connection timeout (errno 111)

Morman answered 27/6, 2012 at 21:23 Comment(0)
B
3

FWIW, having spent around 2-3 months looking into this in a variety of ways, we have come to the conclusion that (at least for us), the (4) error happen when the network is too full of data for the connection to complete in a sane amount of time. from our investigations, the (4) occurs midway through the handshaking process. You can see this in a unix environment by using 'netem' to fake network congestion.

The quick solution is to up the connection timeout parameter. This will hide any (4) error, but may not be the solution to the issue. The real solution is to see what is happeneing at the DB end at the time. If you are processing a lot of data when this happens, it may be a good ideas to see if you can split this into smaller chunks, or even pas the processing to a different server, if you have that luxury.

Boynton answered 27/6, 2013 at 16:29 Comment(0)
C
1

I happened to face this problem. Increase the connect_timeout worked out finally.

Calcification answered 16/8, 2013 at 16:7 Comment(0)
P
0

I was just struggling with the same issue.

Disable the DNS hostname lookups solved the issue for me.

[mysqld] ... ... skip-name-resolve

Don't forget to restart MySQL to take effect.

Proportionable answered 17/10, 2013 at 4:7 Comment(0)
P
0

@cdhowie While you may be right in other circumstances, with that particular error the (4) is a mysql client library error, caused by a failed handshake. Its actually visible in the source code. The normal reason is too much data causing an internal timeout. Making 'room' for the connection normally sorts it without masking the issue, like upping the timeout or increasing bandwidth.

Peoria answered 19/7, 2014 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.