Usually, when you experience such an error it’s related to your MySQL application. Most probably your MySQL is getting killed for some reason, either because it can’t handle the traffic or your Droplet is having high load.
When this happens I recommend SSHing to your Droplet and checking if MySQL is actually running.
sudo netstat -plt
The netstat command prints information about our server’s networking system. In this case, you want the names of programs (-p) listening for connections (-l) on a tcp socket (-t). Check the output for a line listing mysqld.
If you find it, you’ll know MySQL is running, if you don’t, then you can start it with:
systemctl start mysql
As mentioned for further debugging you can try and see:
Another thing you can try is to add SWAP to your Droplet. Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.
WordPress is one of the most popular open source content management systems in the world. Although it started out focused on blogging, over the years it has developed into a more flexible platform for websites in general. After almost fifteen years of development it is quite polished and robust, yet issues can still come up.
If you've recently attempted to load your WordPress-powered website and instead saw a message stating "Error Establishing Database Connection", the cause is most often...