python system_error ai_generated true

django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

ID: python/django-db-connection-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-12-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

MySQL server is not running or socket path is incorrect.

generic

中文

MySQL服务器未运行或套接字路径不正确。

Workarounds

  1. 85% success
    Start MySQL service: sudo systemctl start mysql

Dead Ends

Common approaches that don't work:

  1. 40% fail

    May still fail if MySQL is not running.

  2. 30% fail

    Doesn't fix the database server issue.