Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CrastyCrap's avatar

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I was trying to install supervisor on my server then after install it , i got the following mysql error

"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'" i tried to stop it and re-launch it but nothing change

0 likes
6 replies
LaryAI's avatar
Level 58

This error message usually indicates that the MySQL server is not running or is not configured correctly. Here are a few steps you can take to troubleshoot the issue:

  1. Check if the MySQL server is running:
sudo service mysql status

If the server is not running, start it with:

sudo service mysql start
  1. Check if the MySQL socket file exists:
ls -l /var/run/mysqld/mysqld.sock

If the file does not exist, try restarting the MySQL server:

sudo service mysql restart
  1. Check the MySQL configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Make sure the socket parameter is set to /var/run/mysqld/mysqld.sock.

  1. If none of the above steps work, try removing the socket file and restarting the MySQL server:
sudo rm /var/run/mysqld/mysqld.sock
sudo service mysql restart

Hopefully one of these steps will resolve the issue.

Snapey's avatar

I can't remember the root cause but try changing to 127.0.0.1 instead of localhost or vice versa

CrastyCrap's avatar

@Snapey it's server not localhost and i can't even access to mysql -u so it's server issue not website issue

CrastyCrap's avatar

I didn't identify the problem so i reinstalled mysql

Please or to participate in this conversation.