I am doing a simple server/client connection using multiprocessing in python 2.7.
When I run the client code in a seperate python shell, the connection is successful, but when I run the application as a whole, I get "socket.error: [Errno 111] Connection refused".
This is the Traceback:
Traceback (most recent call last):
File "./kaboom", line 276, in <module>
sequence.run(testEnv)
File "/e/m/amoreau/test_edit/kaboom/src/kbmSequence.py", line 271, in run
if testEnv.open() != SUCCESS:
File "/e/m/amoreau/test_edit/kaboom/src/kbmTestEnv.py", line 518, in open
queueManager = resultsClient.QueueServerClient()
File "/e/m/amoreau/test_edit/kaboom/resultsClient.py", line 15, in QueueServerClient
manager.connect()
File "/usr/lib64/python2.6/multiprocessing/managers.py", line 474, in connect
conn = Client(self._address, authkey=self._authkey)
File "/usr/lib64/python2.6/multiprocessing/connection.py", line 143, in Client
c = SocketClient(address)
File "/usr/lib64/python2.6/multiprocessing/connection.py", line 263, in SocketClient
s.connect(address)
File "<string>", line 1, in connect
socket.error: [Errno 111] Connection refused
Why does this happen? I have disabled all firewalls.
For example, the classic Connection refused errno 111 means that the initial SYN packet to the host you connect() to was responded with an RST packet instead of the normal SYN+ACK — which usually happens when there's no program listening to the given port on the remote computer you connect() to.
Howdie, I just had this problem. I know this is an old answer, but I found the answer in a related question. It's listed below. The issue is that the client is attempting to connect to the server before the server has created the socket.
Well, that's what it was in my case. Spawning the server off into another process takes a wee bit longer then the client attempting to connect. To test, I placed a sleep call in my client and sure enough, no more error.
Python Socket Error - Connection Refused
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With