Question

I get WordPress errors like "Error establishing database connection" and "Currently unable to handle this request." Do I need to resize?

Posted May 20, 2019 627 views
WordPressUbuntu 18.04

Every now and then, while working in my WordPress dashboard, I will get an “Error establishing database connection” (at which point I have to reboot my droplet) or “Page isn’t working. Currently unable to handle this request.” This usually happens when I’m doing something like running a virus scan or editing a bunch of posts at once (by opening them all up in separate tabs and updating them simultaneously since doing them one by one is too slow). Does this mean I need to resize my kernel? I’m currently running on the $5/mo plan with 1GB of memory. I’m about to open an ecommerce store and I’m worried that the site will go down while customers are shopping.

1 comment

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
2 answers

There are two possible culprits, one is that you are running out of max connections to the DB, but it seems unlikely because you highlighted just opening a couple of tabs can sometimes cause the problem.

The second issue which is more likely is that you maybe running out of resources. Depending on what plugins you have installed in Wordpress and how you are using them it can take up a lot of memory and resources, especially if you are running a long lasting process in parallel.

What you can do is login to your droplet while you are performing these various actions and check the output of the “top” command to see how your CPU and memory usage is performing.

Normally we would recommend using something larger than a $5 droplet for Wordpress only because it can be very CPU and memory intensive.

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 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 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/

Source:
https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

Hope that this helps!
Regards,
Alex