Python 2.7 : socket.error error [Errno 111] - connection refused

42,087

'Connection refused' means there was nothing listening at the IP:port you tried to connect to.

It comes from the target system, which means that the connection request got there and the refusal came back, so it isn't a firewall issue.

Share:
42,087
Admin
Author by

Admin

Updated on March 03, 2020

Comments

  • Admin
    Admin about 4 years

    I created a TCP server program (see server.py) to access the terminal of another computer (see client.py). When I use the client and server locally (only on my computer) everything is fine, however when the client is sending a request from a different computer, I receive this message on the client side :

    Traceback (most recent call last):
      File "client.py", line 11, in <module>
        client.connect((serverIP, serverPort))
      File "/usr/lib/python2.7/socket.py", line 228, in meth
        return getattr(self._sock,name)(*args)
    socket.error: [Errno 111] Connection refused
    

    Note : the server is the computer which is being accessed by the client.