“[Errno 61] Connection refused” is occurring even, the program is connecting with the port well and the socket is running in the interfaces.

If you see the “[Errno 61] Connection refused” issue although you checked the program, port, socket and interfaces. Although your program of Python works well in the server and the client, they are installed at the same device. The local IP from my device is connecting with the clients but this IP is not connected with the IP from your own.  You don’t know why it happened and how to correct them. Don’t worry about this problem because we will help you fix them and you are able to follow our simple instructions to solve it by yourself.  Click the below to explore this cause and answers also. 

Why does the “[Errno 61] Connection refused” problem happen?

You find the “[Errno 61] Connection refused” issue when you try to connect the address of public IP from your device to the client. The bind((“”, 50000)) is identified by the connection between the server and interfaces and it is forwarded to the router. When your program is attaching with the port, it is installing by netstat -an | grep LISTEN. After that, the command below is running:

 tcp4 0 0 *.50000 *.* LISTEN

If you sign up for the tool connection in the online program, you can check the port whether it is opening or closing.

If the connection between your program port and client is losing and you don’t know why it is. That can be identified that you use the code at the same device for your server and the client. So, it doesn’t work and here is that command:

tcp_client = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
tcp_client.connect(('my_public_ip', 50000))

How to resolve this error?

To narrow the problem for your server and the client, try to connect from your public IP to another network such as the machine of a friend, neighbor or someone else. They are different from the home connection of the system at your home. If you connect with outside’s network and it does work, the issues that you suspect in your public one are right. So, connect from your public IP to outside’s network to run the system well.

Otherwise, you can put a stage name to the local of your interfaces (ip addr add dev eth0) if you still want to use the public IP all time. However, the simplest way is using your address on your local connection. You can access and check regularly even if this system is far-off. 


I hope this article provides useful information to connect with your program if you have “[Errno 61] Connection refused” problem. If you have any concerns, please let us know by the below comment box. Wishing you all a great day!

Scroll to Top