• I am not an expert, but I do host a few wordpress site on a LAMP stack with nginx web server. Following is the configuration:

      Debian 8.9 x64
      nginx 1.6.2
      PHP 5.6.30
      mysql 15.1
      host: Digital Ocean

    Since a few months I randomly get the error “Error Establishing a Database Connection” almost every 24 hours. So I open terminal and reboot the server after logging in via ssh. Almost everyday when the site goes down I reboot, and the sites comes back on. I am not able to find how to start troubleshooting.

    Please help

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator t-p

    (@t-p)

    If the error is intermittent then it’s your server.

    What’s happening is that the web server and/or the database server are gettign overloaded and the connection is droping out or is refused for a short time. That gives you the database error as the website can’t connect to the database.

    To fix this, you’ll need to talk to your hosting company as they are the only ones that can do anything about hardware issues like this.

    Thread Starter Vy0m

    (@vy0m)

    Thanks for replying.

    I am not sure if it’s a hardware issue. Currently I host about 4 different wordpress sites on a 20 GB SSD and 512 MB RAM VPS from Digital Ocean. Is that configuration too less for hosting 4 different wordpress sites, which don’t even get that much traffic as of now? (not even 150 views daily from all 4 sites combined).

    Btw, it just went down again. I got following error when I tested the connection using a php code:
    Could not connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111 "Connection refused")

    So I tried attempting to restart only mysql, php5-fpm and nginx. None of which helped my sites go back online. So I again rebooted whole VPS. And then the sites came back online.

    • This reply was modified 6 years, 9 months ago by Vy0m. Reason: edited more to less
    Moderator t-p

    (@t-p)

    So I again rebooted whole VPS. And then the sites came back online.

    Glad to know it ??

    Thread Starter Vy0m

    (@vy0m)

    But the problem is not solved. My site goes down almost every 24 hours (and even less). I reboot VPS and site comes back online. Don’t know how to troubleshoot what makes my sites do down. ??

    512M is not a lot of ram for a database.
    Have you configured it or are you using the defaults?
    Try https://github.com/major/MySQLTuner-perl for some tuning hints.

    Also php5 uses 3x more ram than php7, you should update that if you can.

    Thread Starter Vy0m

    (@vy0m)

    I dont understand what you mean by “have I configured it?”. I have changed themes, installed various plugins, yes. But not a lot of them.

    Right now planning to migrate sites one by one to a new VPS to isolate problem.

    have I configured it?

    I mean did you configure mysql? Or did you just install it?
    The default mysql config is very limited and isnt meant for a 512M vps either.

    • This reply was modified 6 years, 9 months ago by Simon Prosser.
    Thread Starter Vy0m

    (@vy0m)

    I don’t remember configuring anything other than just setting up databases to be used by wordpress. So does that mean, it might be the culprit.

    Were you able to resolve this? I am getting the same connection error for the past 2 mornings. I migrated my site from goddady to Google cloud several days ago. After i reset the VM instance, the site is back up.

    Thread Starter Vy0m

    (@vy0m)

    I never really did find out. I had a few websites hosted on my VM. I one by one created replicas of my sites on a new VM, (not migrated, since then issue would have been migrated too). Then I discarded old VM. This issue never occured in new VM. But it did took quite a lot of efforts in recreating all sites on new VM.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘LAMP setup with nginx, Get Randomly, “Error Establishing a Database Connection”’ is closed to new replies.