Mail stuck in the queue in the server with Plesk: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)




  • Avatar
    Mikhail Krivoshein

    The issue is still open. Just faced on AlmaLinux host.

    First of all, to verify if you suffer from this problem, run:

    ls -Zl /var/lib/mysql/*sock

    If you see anything other than the line below, you probably experience this issue exactly.

    srwxrwxrwx. 1 mysql mysql system_u:object_r:mysqld_var_run_t:s0 0 May 29 16:30 /var/lib/mysql/mysql.sock

    On systems that run systemd it is possible to configure a command to run after service has started. Modify /etc/systemd/system/mariadb.service.d/override.conf and add lines below:

    # Workaround so socket gets correct linux context
    ExecStartPost=chcon -t mysqld_var_run_t /var/lib/mysql/mysql.sock

    then do configuration reload and mariadb restart:

     systemctl daemon-reload
     systemctl restart mariadb

    Verify if it helped with ls command. If it did help, verify it still works after host reboot. 

    Comment actions Permalink
  • Avatar
    Jon Ireland

    I get the following error with this work around any ideas?

    Task "/usr/sbin/restorecon -v /var/lib/mysql/mysql.sock​" completed with error in 0 seconds, output:
    /usr/sbin/restorecon: lstat(/var/lib/mysql/mysql.sock​) failed: No such file or directory
    Comment actions Permalink
  • Avatar
    Md Rasel Khan

    Number 5 step should I run one time right? No need to set cron job for this, right?

    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request