Reputation: 1348
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
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