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
This could be because of proxy or firewall. If it's proxy, then you need to specify proxy setting at entry point of your code or project.
import os #for proxy
proxy = 'http://10.XX.XX.XX:8X8X' #your own proxy 'http://<user>:<pass>@<proxy>:<port>'
os.environ['http_proxy'] = proxy
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_PROXY'] = proxy
#rest of code .....
The solution is to use the same IP and Port number in both client and server. Try, in client to use TCP_IP = 'write the ip number here' TCP_PORT = writ the port number here s.connect((TCP_IP, TCP_PORT))
Hint: actively refused
sounds like somewhat deeper technical trouble, but...
...actually, this response (and also specifically errno:10061
) is also given, if one calls the bin/mongo executable and the mongodb service is simply not running on the target machine. This even applies to local machine instances (all happening on localhost).
➪ Always rule out for this trivial possibility first, i.e. simply by using the command line client to access your db.
See here.
The below changes fixed my problem.
I struggled with the same error for a week. I would like to share with you all that the solution is simply host = ''
in the server and the client host = ip
of the server.
10061 is WSAECONNREFUSED, 'connection refused', which means there was nothing listening at the IP:port you tried to connect to.
There was a firewall product around the year 2000 that issued refusals instead of ignoring incoming connections to blocked ports, but this was quickly recognised as an information leak to attackers and corrected or withdrawn.
There is no relationship between error and firewall.
first, run server program,
then run client program in another shell of python
and it will work