FidelM
By:
FidelM

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

July 24, 2017 431 views
DigitalOcean Logging MySQL WordPress Ubuntu 16.04

Error message: " Error establishing a database connection"

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 https://sitecheck.sucuri.net 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?

Have another answer? Share your knowledge.