Search code examples
pythonsocketstcpclienttcpserver

Python, tcpServer tcpClient, [WinError 10061]


When I try to run tcpServer and tcpClient on the same local network, it works, but I can't run them on the external network. The OS refuses the connection.

Main builtins.ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

I checked whether tcpServer is running or not using netstat, and it is in the listening state.

What am I supposed to do?


Solution

  • There are most likely two reasons for that:

    1.) Your server application is not listening on that particular ip/port

    2.) A firewall is blocking that ip/port

    I would recommend checking your firewall settings. You could start with turning your firewall off to determine if it really is a firewall issue.

    If so, just add an accept rule for your webservice (ip:port).

    edit: And check your routing configuration if you are in a more or less complex network. Make sure that both networks can reach each other (e.g. ping the hosts or try to connect via telnet).