Skip to content Skip to sidebar Skip to footer

(python) Socket.gaierror: [errno 11001] Getaddrinfo Failed

I'm not sure whats wrong with this code I keep getting that socket.gaierror error ;\ . import sys import socket import random filename = 'whoiservers.txt' server_name = random.ch

Solution 1:

I think the problem is a newline at the end of server_name.

If the format of your file whoiservers.txt is one hostname on each line then you need to strip the newline at the end of the hostname before passing it to s.connect()

So, for example, change the open line to:

server_name = random.choice(list(open(filename)))[:-1]

Solution 2:

Perhaps you have a firewall in between you and these servers that is blocking the request? The last error you posted leads one to believe that it cannot connect to the server at all...

Post a Comment for "(python) Socket.gaierror: [errno 11001] Getaddrinfo Failed"