Scapy import error 'socket.gaierror: [Errno 11001] getaddrinfo failed'

Im trying to install Scapy on windows 10, python 2.7.11, and stuck on this error:

>>> from scapy.all import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\tools\python\lib\site-packages\scapy\", line 25, in <module>
    from scapy.route import *
  File "C:\tools\python\lib\site-packages\scapy\", line 182, in <module>
    _betteriface = conf.route.route("", verbose=0)[0]
  File "C:\tools\python\lib\site-packages\scapy\", line 150, in route
    aa = atol(a)
  File "C:\tools\python\lib\site-packages\scapy\", line 400, in atol
    except socket.error:
socket.gaierror: [Errno 11001] getaddrinfo failed

What does it mean?

1 answer

  • answered 2018-03-13 20:29 Fire

    As stated in the python 2.7 documentation, this error is thrown either by the getaddrinfo() or getnameinfo() function.
    Judging by the stack trace, the scapy module tries to initialize a socket during its import and the port number is invalid (we can see the atol function being called, which convert a string to an integer).
    It is unclear what the real issue is. However, you can try the following things:

    • Make sure you have the right version of python and scapy. I suggest that you install scapy from pip, and maybe use a virtual environment to run your script.
    • You can also try to compile scapy from source, or check the issue section in github to see if your problem is actually a known problem being worked on.
    • Maybe scapy tries to initialize a raw socket (i don't know why they would, but its worth a try), which requires admin privileges. Try running your script as admin.

      Hope this helps