I have a droplet with Ubuntu 22.04 LTS and Apache, PHP, MySQL and Wordpress set up. Everything works flawlessly for a few days or weeks. But then, I check my sites and the browser says: “Error establishing a database connection”. Then I log in to the droplet, restart the system via console and everything goes back to normal. Everything works fine for a few days and then, out of nowhere, the same error happens: “Error establishing a database connection”, when trying to access the sites. I guess it’s something related to MySQL. Why does it happen? And how can I fix it and prevent it from happening for good, so the sites will work properly without the need of manually reseting the server from time to time?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.