WordPress: Error establishing a database connection

Are you running your own web server in the cloud?

I hope you have some monitoring setup to get email alerts when it's offline 😀 

Yesterday, I knew something was wrong, after visiting my website around 18:00 C.E.T. to check a link, the Chrome browser started returning "Site can't be reached". I assumed it was WordPress running auto-updates, as there had been some recently. Later around 20:00 in the evening the website was reachable and I made some changes. Then, this morning this...

 

I've been running my own web server on AWS for a while now, so I know it's time to log back into the server. Of course, the connection doesn't work, because my IP has changed which means it's also time to update the AWS security group.

Click edit!

Now the SSH connection works, which reveals all...

Reboot required...

but first you might want to run a couple of commands like

sudo apt-get update

sudo apt-get upgrade

and only then

sudo reboot

The dashboard also tells an interesting story (note times are not C.E.T.).

Sometimes the AWS monitoring dashboard can be very handy to have. Here we just see that the T2 burst compute balances went down significantly. If I had an online shop running here I would be panicking.

You'll see in the top right IOPS, I find this statistic interesting in that it shows how efficient the server is running. Have a look at the difference between my Ubuntu v16 and v18 servers. 

Here is how I added IOPS to my dashboard; get the read and write bytes, then divide them 300 (the data is coming at 5-minute intervals).