I'm trying to run an OLD (2018) Django project on localhost.
However, when I use: python manage.py runserver 192.168.23.12:8000
I get from Python37\site-packages\pymysql\connections.py
:
line 600, in connect
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
AttributeError: module 'socket' has no attribute 'AF_UNIX'
I'm using a Window machine and I tried also to change AF_UNIX
to AF_INET
getting:
AF_INET address must be tuple, not str
CodePudding user response:
Based on the elaboration in the comments:
The error stems from the Django MySQL machinery attempting to use an UNIX domain socket for connecting to MySQL, since it has been told to do so via the settings.py
file's database HOST
.
However, there are no AF_UNIX sockets on Windows, so that's bound to fail.
The fix is to use a TCP socket to connect to MySQL; that is, change the MySQL HOST
to e.g. localhost
instead of a socket path /var/lib/mysql/mysql.sock
.