I have a query being compiled in a template but by the time it's run, it appears that the query module has lost it's connection to the DB:

Error Number: 2013

Lost connection to MySQL server during query

..query here...

Filename: modules/query/mod.query.php

Line Number: 181

Is there any way to extend the database connection period so this can be avoided?

1 Answer 1


Sounds like you need to increase the connect_timeout setting in my.cnf or adjust your query so it processes faster. If you aren't on a VPS, you'll have to contact your host to figure out how you make the my.cnf change in their setup.

  • I was looking at that and the default is 10 seconds, however this error displays in less than 1 second of refreshing the page. It's a fairly nasty statement with some nested selects, but there are only 4 rows to query so it wouldn't expect to baulk on a vps with 2gb ram running on it. Or at least not to time out until something more meaningful, like 10 seconds.
    – Russ Back
    Mar 21, 2013 at 16:06
  • Just ran the query locally in sequel pro and it takes less than 17ms to run. Stumped.
    – Russ Back
    Mar 21, 2013 at 16:09
  • I'd suggest contacting the web host. They might be able to see on their end why the connection is failing.
    – Anna_MediaGirl
    Mar 21, 2013 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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