I have a problem with these client and server codes, I keep getting the [Errno 10061] No connection could be made because the target machine actively refused it
instead of localhost of '0.0.0.0', use local network address as host in case of both - the server and the client - code.
host = '192.168.12.12' port = 12345
use this host address when binding and connecting to the socket.
server.bind((host, port)) client.connect((host, port))
this change solved the issue for me.
if you have remote server installed on you machine. give server.py host as "localhost" and the port number. then client side , you have to give local ip- 127.0.0.1 and port number. then its works
Using the examples from: https://docs.python.org/3.2/library/socketserver.html I determined that I needed to set the HOST port to the machine I had the server program running on. So TCPServer on 192.168.0.1 HOST = TCPServer IP 192.168.0.1 then I had to set the TCPClient side to point to the TCPServer IP. So the TCPClient HOST value = 192.168.0.1 - Sorry, that's the best I can describe it.
I was facing a similar problem when I was calling REST API using python library and what I found that my server was going into sleep mode which was leading to this. As soon as I logged in to the server via Remote Desktop Connection, my API call used to work.
The first: Please make sure your port '12345' is opening and then when you using a different network. You have to use the IP address in LAN. Don't use the 'localhost' or '127.0.0.1'. The solution here is: In server
host = '192.168.1.12' #Ip address in LAN network
In client
host = '27.32.123.32' # external IP Address
Hope it works for you
the short term solution is to use the default iis host and port normally 120.0.0.1 and 80 respectively. However am still looking for a more versatile solution.