I have a chatroom on my webpage that refreshes every 5 seconds, and it works fine, BUT occasionally I would get this error when it refreshes

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (2) in /home/luved/public_html/dbconn.php on line 6
Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (2)

I'm thinking maybe it has something to do with the constant connecting to MySql?
I hope not because I don't want to have to get rid of the chatroom. maybe have it refresh less?
any suggestions?