Error establishing a database connection

  • Posted June 29, 2014

Hi all, I am running a wordpress website on Ubuntu 12.04, everything looks fine but sometimes i get out of the blue: Error establishing a database connection. When i restart the server with “reboot” in putty, everything seems fine. So it seems like the mysql server crashes or something… Can someone help me with this, it is really frustrating that i have to reboot it once or twice a day. Thank you


Submit an 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.

Hmm i cannot get this to work:

root@dailyblackcoin:~# sysctl -w vm.dropcaches=3 sysctl: cannot stat /proc/sys/vm/dropcaches: No such file or directory root@dailyblackcoin:~# sysctl -w vm.dropcaches=3 or echo 3 > /proc/sys/vm/dropcaches -bash: /proc/sys/vm/dropcaches: No such file or directory root@dailyblackcoin:~# echo 3 > /proc/sys/vm/dropcaches -bash: /proc/sys/vm/dropcaches: No such file or directory

Hi there,

You need activate the swap in your droplet.

Please, follow this:

sysctl -w vm.drop_caches=3 or echo 3 > /proc/sys/vm/drop_caches sudo swapon -a or sudo swapon + partition_of_swap Ex: sudo swapon /dev/sda2

To permanent configuration, add it into /etc/fstab vi /etc/fstab and add: /dev/sda2 swap swap defaults 0 0 Reboot the droplet and be happy!

If you think that mysql server is the problem try to enable mysql log files. Also on which package your website runs? 512mb? You probably are running low on memory. By the way you can set up a cron job to restart your server