Hi all! So, my site has been down several times this past few days. I am running a self hosted wordpress site using Umbuntu.

The other day I had an error establishing a database connection so when I run curl -I and tail, I didn’t saw anything particular so when I restarted the apache the site run back normally.

However, today the site was down again and when I run tail it showed that apparently I lost connection to MySql database therefore I did a series of apache and mysql restarting and now my site is back again.

My question is, what normally drives this kind of errors and if ever there is a problem with mysql, how can I fix this? Below are the logs from the latest moment my site was down.

It is down again and when I try curl:

HTTP/1.1 500 Internal Server Error
Date: Sun, 01 Nov 2015 08:36:40 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.11
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Connection: close
Content-Type: text/html; charset=utf-8

And here’s the tail result:

[Sun Nov 01 07:10:58.648191 2015] [:error] [pid 17859] [client 5.8.66.115:47686] WordPress database error Lost connection to MySQL server during query for query select val from wpwfConfig where name=‘disableConfigCaching’ made by include('wp-load.php’), requireonce('wp-config.php’), requireonce('wp-settings.php’), includeonce(’/plugins/wordfence/wordfence.php’), wordfence::install_actions, wfCache::setupCaching, wfConfig::get, wfDB->querySingle

I don’t understand most of the problem which the tail gave me except for the lost server from MySql. I wish to fix this problem and I think restarting it is just something temporary because if there’s something bigger behind this downtime, I really wish to fix now.

This forum has been so helpful and I really enjoy the learning progress everytime I recieve a downtime but recently I’m getting quite a bit of traffic and the down time has been affecting the flow :(

Thanks all!

1 comment
  • I’m receiving some heavy traffic from the IP you’re mentioning here (5.8.66.115) :(
    Cloudflare is helping me out!

    5.8.66.115 - - [02/Nov/2015:16:42:44 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:45 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:46 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:47 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
    

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.

×
Submit an Answer
4 answers

Most likely OOM killer, check your syslog.

I’m receiving some heavy traffic from the same IP (5.8.66.115) :(

5.8.66.115 - - [02/Nov/2015:16:42:44 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:45 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:46 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:47 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
5.8.66.115 - - [02/Nov/2015:16:42:49 -0500] "POST /xmlrpc.php HTTP/1.0" 404 463 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"

Maybe late answer, but you could try to change the value for php fpm in www.conf.

Change:
pm.maxchildren = 100
pm.start
servers = 20

To:
pm.maxchildren = 10
pm.start
servers = 10

This will avoid php to eat your memory when you got more traffic to the site.

Hello, all

You will most definitely need to upgrade your droplet as you’re running out of memory and your application/website needs more resources in order to continue to operate.

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

https://www.digitalocean.com/products/managed-databases-mysql/

This was mini tutorial was posted from bobbyiliev in this question in our community: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

You can also create a simple bash script to check if MySQL is running and if not to restart it.

#!/bin/bash

# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart
fi

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/monitor.sh > /dev/null 2>&1

Hope that this helps!
Regards,
Alex