gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra)

There is an answer in OP’s comments based on another question, which requires to edit /etc/hosts, i.e echo 127.0.0.1 $HOSTNAME >> /etc/hosts.

Alternatively, you can use socket.gethostbyname('localhost'), assuming that localhost is what you need and it is defined in your /etc/hosts.

Leave a Comment

error code: 521