bixente57
bixente57

Reputation: 1348

Simple socket call returning socket.gaierror: [Errno 8]

I have this really simple code:

print(socket.gethostbyname(socket.gethostname()))

That should be returning my IP adress.

But it is returning an error:

socket.gaierror: [Errno 8] nodename nor servname provided, or not known

Any idea?

Some details:

socket.gethostname()

returns:

'airdevincent2'

Upvotes: 1

Views: 1320

Answers (1)

bixente57
bixente57

Reputation: 1348

Answer found!!!

I am on MacOs and the /etc/hosts file didn't contains any mention to the "airdevincent2" host.

So I added this line:

127.0.0.1   airdevincent2

Et voilà!

Upvotes: 2

Related Questions