Error Establishing a database connection issues

I’m relatively new to using digital ocean and VPS hosting in general. I recently used the “how to debug Wordpress” tutorial and based on the results, I’m running out of memory.

I don’t see how that’s possible. It’s a single page website with no traffic. The server has 1g of memory and 30gb of disk space. Furthermore, I have multiple websites running on the 5$ version of DigitalOcean that don’t run into this issue even though they have many pages and receive some traffic.

Is there any way for me to see what’s eating up all my memory?

Also, I followed the instruction on how to turn off XML-RPC so that won’t be the cause.

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

This was mini tutorial was posted from bobbyiliev in this question in our community:

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


# 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

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

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

Hope that this helps! Regards, Alex

Hey, everyone, I’m back. So basically I’m still ocasionally running into the same problem. I have five different digital ocean servers. Three of them run perfectly fine on $5 servers with more traffic and web pages. There’s absolutely no reason this $10 server should be running out of memory.

I’ve been routinely monitoring htop and at no point does my memory reach the upper limits. However, for some reason, my error log is showing my server as running out of memory.

I even went so far as to make a snapshot of my data and create a new droplet, put that snapshot on a new server. This hasn’t made things any better.

It has to be one of my plugins or somehow my database is messed up. I’m considering making a new droplet and recreating my website from the ground up. It’s only a few pages so it won’t take too long. However, I don’t want to have to resort to this.

@semipro Install htop on the other server as well. It doesn’t cost any RAM or CPU, when it’s not running. Then look at the differences in like Apache, MySQL, etc.

Are you running the same version of Ubuntu, Apache, PHP and MySQL on both servers?

When MySQL crashes, then before starting it again, run tail -50 /var/log/mysql/error.log