Report this

What is the reason for this report?

Database connections timeout

Posted on August 4, 2016

Persistent database connections to MySQL and Redis servers don’t stay open for more than a couple of minutes before connection is dropped. This issue came up since we switched to node applications in cluster mode that keep around 30 - 50 connections open at any time. Most common error is “MySQL server has gone away” that is usually handled in application logic, but lately errors like “Lost connection to MySQL server during query” and 111 “Connection refused” started coming up, which are not handled cleanly.

Even PHP applications that keep only one non-persistent connection have random connection issues. On top of that even remote SSH to server drops occasionally.

All our servers run in SF1 region. Any ideas what would be causing these connections issues?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Sorry for the late reply. With those persistent connections it’s possible that you are running out of listeners (with all the slots full with persistent connections and the short term php ones as well new clients may be getting denied or dormant connections freed up).

I would recommend reviewing my.cnf (in /etc/mysql) to see what your max_connections variable is set to. With the persistent connections, check the wait_timeout value in case MySQL is timing out these connections when they are idle.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.