Random WordPress "Errorr Establishing Database Connection" errors, every 1-2 days

My Wordpress website is going offline every 1-2 days, with this error. The site was built using EasyEngine 3.

Looking at the stats, just before this happens I get a jump in Disk I/O reads from virtually 0 MB/s to about 0.89MB/s

Can anyone give me a few tips in order to effectively troubleshoot this, e.g what are the best logs to check (MySQL) etc?

This has been happening for a couple of weeks.

Many Thanks Az

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Hello all,

This crash is most likely due to your system running out of memory. I’d suggest that you add a swap file to give yourself a bit more of a buffer. Check out this tutorial:

How To Add Swap on Ubuntu 18.04

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 -O
  • Then execute it:

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 worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:


Hope that this helps! Regards, Alex

Thanks for your help Jarland. Ironically, this hasn’t reoccured since your post, so I can’t check it.

Can you recommend specific logs to look at? I’m not that au fait with Linux, or mySQL.

I’ve reviewed the Wordpress optimisation link you included, and I’m already covered there - I use lot of the caching strategies mentioned, including cloudflare.

I found that they could also be an XML-RPC attack, but the logs don’t indicate this.

Thanks again, and best wishes for your Thanksgiving.


Hey friend,

I would recommend logging in to the web console in our control panel. Click in the black area, press Enter to bring the display up. I’m expecting you to see out of memory process kills. Here’s an example of what that looks like:

What this means is that your Wordpress installation is sometimes using more memory than you have available. You can either optimize Wordpress to reduce memory usage or upgrade to more memory.

I recommend having 2GB of memory in this situation. If you have that, I would focus on optimizing Wordpress.