Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My website always ran fine, but since this morning I'm getting the following error randomly, most of the time when I quickly refresh the page while it's refreshing:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

When I try to login with LiveZilla I have the following error: MySQL server has gone away.

All these errors since this morning. I've already rebooted, didn't work. I'm running Debian 5 x86 with DirectAdmin if that's needed.

share|improve this question

migrated from stackoverflow.com May 16 '11 at 18:49

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

It could be that your server is down or /tmp/mysql.sock was a symlink that no longer exists, try running:

find /var -iname '*mysql.sock'

If you do see a result, like /var/lib/mysql/mysql.sock, then recreate the symlink:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
share|improve this answer
@onteria_ No, there's no result. The mysql.sock can be found though, since 20% of the time you get the error (so 80% of the time it works fine). –  Devator May 16 '11 at 11:06
@Devator Might want to check hardware to narrow that down. Often unreasonable and random errors can be signs of something like bad memory or bad disks. If it's hosted somewhere else ask them to check for you. –  onteria_ May 16 '11 at 11:09
@onteria_ It's a VPS. I've already asked them and they basically said "everything is fine". -.- –  Devator May 16 '11 at 11:17
@Devator Next step would be to debug the code that does your SQL calls. A lengthy process but it may help you pinpoint the root cause. –  onteria_ May 16 '11 at 11:20
@onteria_ How would you debug a simple mySQL SELECT query? –  Devator May 16 '11 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.