How to Solve NameError: name 'error' is not defined -- socket

Solution: Import the 'error' module

To Solve the error, add the following line to the top of your code.

from socket import error

 

For more information:
Python socket error