Error when i access wordpress site in a browser. Site is on wordpress droplet at Digital Ocean. "Error establishing database connection"

Posted July 24, 2017 3.1k views
MySQLWordPressDigitalOceanLoggingUbuntu 16.04

Error message: “ Error establishing a database connection”

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

Hi @FidelM

Without seeing the database error log, then the best guess would be that you’re running out of RAM, so if you have a $5 droplet, then resize it to $10.

And if you are using CloudFlare’s offline-cache, then you need to setup some cache, since it visits every page within a very short time, which can easily drain the server for RAM.

Run the following command to show the last 40 lines of the database error log:

tail -40 /var/log/mysql/error.log
  • Hi Ansen,
    I have RAM of 1GB and droplets of $10.
    I ran the command to show the last 40 lines of the database error log:

      tail -40 /var/log/mysql/error.log       Thanks for this. I was able to read through the logs.

    However, I had earlier performed a site cleanup using and the results showed that it was internal server errors.
    I then had to restore a snapshot/image of the droplet that I had taken 2 months ago.
    My wordpress sites are up and running on well!

    • @FidelM

      The Site Check at Sucuri can hit your server very hard, so running that test actually creates like 50+ requests within a very short period. That would be enough to crash your database if you were low on RAM.

      But glad to hear you’re up and running again.

same error for me, i have 2 droplet with same wordpres site and details one crash and one work nice, WHY?