Couldn’t connect to databasee

Posted on

Question :

I have a dedicated webserver and a dedicated database server.

Often, I get errors connecting to the database server

couldn't connect to database

Here is my current /etc/my.cnf configuration file

max_allowed_packet = 100M


nice = -10

How can I increase the timeout connect for the database server?

Answer :

Actually I do not think this is something you would want to change under nearly any circumstances. You should not fix the symptom, but should find out the problem.

Does the mysql log contains information about aborted connections? Does the syslog of that server contain information which might be relevant? Do you run a more or less decent version of mysql? (At least the most current minor version.) Have you checked if the database server runs out of resources (e.g. RAM, because swapping is really bad for any DB server)? Have you compared the number of connections your webserver maximally issues simultaneously to the db server and the number of connections your db server is processing in parallel from its configuration file?

Have you tried pinging the database server from the web server for a long period of time? Does the ping slows down (or gets lost) too, when the error message pops up in your application?

You should check all that before you change anything in timeouts.

Leave a Reply

Your email address will not be published. Required fields are marked *