ralph
By:
ralph

Error establishing a database connection

June 29, 2014 2k views

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

3 Answers

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

Hi there,

You need activate the swap in your droplet.

Please, follow this:

sysctl -w vm.dropcaches=3 or echo 3 > /proc/sys/vm/dropcaches
sudo swapon -a or sudo swapon + partitionofswap
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!

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

Have another answer? Share your knowledge.