DNS redirecting and bringing website down

I have been using CF for a couple of years without issue. Lately my website has been going up and down for a few minutes a day (reports from pingdom) now the site is completely down with this error message displaying:

Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111) in /var/www/html/wp-includes/wp-db.php on line 1520

How do I fix the problem? I think it’s a DNS autoredirect, but I’m a novice and don’t know how to fix it.

Hi. This is a PHP error. I’ll see if I can help but it involves some questions and more info from you, which you may not be able to provide but that’s ok…

  1. Can you describe your hosting environment? Is this shared hosting or a VPS that you have full control over?
  1. Does this happen at the same time every day? I.e. do you know if this is perhaps a daily reboot of the server?
  2. Can you verify that MySQL is actually running at this time? If this is shared hosting you’d likely need to contact your hosting provider’s support for their verification. If this is a VPS that you’re running yourself you would need to do something like ps -aux | grep mysql to verify a running process.
  3. In some cases, when MySQL is running on the same server, the mysql_hostname is set to localhost and changing that to can rectify this issue.

Thanks Andy!

I built the wordpress site on our own servers and it is a Virtual server. I then set-up Cloudflare a couple years ago. The wordpress version is a couple versions behind.

Is your server some flavor of Linux running Apache?

Since you’re running the server and your site is currently down here are some things I would do.

  • Reboot the server (if it hasn’t been recently) and see if this resolves the issue
  • SSH in and check to see if MySQL is actually running. If it’s not then you need to start the service - the command varies based on Linux distro
  • If there are updates available for your distro you may consider applying them though that is ultimately up to you. I believe mysql_connect has been deprecated in the current PHP7 for example.

Eventually once you are able to connect to MySQL and access your Wordpress admin you should update that as well. Your issue isn’t really related to Cloudflare at all, and since you know more about your server than I do, I would recommend googling some things if you’re so inclined - though I am definitely around to help troubleshoot this as well :nerd_face:

1 Like

Thanks Andy. I’ll give the reboot a shot

1 Like