close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

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

Today I get the following error gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) in python.

How To Solve gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) Error ?

  1. How To Solve gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) Error ?

    To Solve gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) Error 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.

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

    To Solve gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) Error 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.

Solution 1

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.

Solution 2

Same problem tome. I change the code to:

import socket
socket.gethostbyname("")

And it works now.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read