Sleeping MySQL connection

Hi, i saw other topics that state that Cloudflare isn’t involved with database connections. I keep receiving “error establishing database connection” messages - and they are resolved when i pause Cloudflare or change my nameservers back to default. When I got in touch with my hosting company regarding this, they responded with the following and I just want to make sure if you know what could be causing these sleeping queries?

There were 5 sleeping queries that were shown (a sleeping query is just a connection to MySQL that has not closed after the MySQL query has completed). When 10 concurrent database connections are made no additional connections to the database can be made as the concurrent database connection limit on our shared server environment is 10. When a MySQL connection is attempted and there are already 10 concurrent MySQL connections made to this database, this will result in the “Error establishing a database connection”. Once these connections have cleared and there are available MySQL slots, the connection will be successful.

I would suggest trying to clarify which part of the website/code is causing these sleeping queries to be generated upon logging into the WordPress admin panel as these queries occupy MySQL database slots for the database your website is connecting to. Cloudflare is used to improve websites security and performance and in turn should have not influence the amount of MySQL connections that are made to the database.

As you mentioned, anything database related is way out of Cloudflare’s scope. The reason why there are sometimes these errors is because people try to connect to their database via a hostname which becomes proxied once the move to Cloudflare, and a proxied hostname cannot, must not, and should not be used for such a connection.

Simply make sure whatever address you are connecting to is either the proper IP address or a hostname which resolves to that IP address and not proxied, and you should be fine.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.