How to prevent: "Error establishing a database connection"?

Hi:

Recently I had “Error establishing a database connection” on a live site witch was shut down for one day. I lost rankings & traffic.

How should I prevent this from ever happening again?

Is it due to mysql down? if yes, then You should optimize it and might be great to have daemon for mysql.

Hi WebH:

Thanks for answering.

Yes, it is due mysql is down. (No database connection - Error)

What “daemon for mysql” means, and how to do it? Do you have a url for a guide to do that?

Also can you give a way to establish the database connection once it is down for EE.V4? (Now I always create a new droplet and run a new EE & Wordpress installation over again. I do it for a live site. This time consuming. And also people coming in to the site see errors untill I finish all the installations).

It may not be a MySQL issue. The downtime may have been cause by lack of resources due to increase of requests.

Always use an uptime monitor service. Personally I prefer ManageWP as it is an all round tool with offsite incremental backups etc. An uptime monitor will notify you (ManageWP does so via SMS) when a site faces issues so you can act fast and most importantly sleep at night.