ConnectionRefusedError: [Errno 111] Connection refused
Nothing is listening on that port
Seen in Python socket, requests, urllib3, asyncio (Errno 61 on macOS)
The host answered but actively refused the TCP connection, because no process is listening on that address and port.
Common causes
- The service is not running, or listens on a different port.
- The service listens only on 127.0.0.1, but you connect from another host or container.
- Inside Docker, "localhost" is the container itself, not the host or another container.
- A firewall rejects the connection with a reset.
How to fix it
- Check the service is running and listening: ss -ltnp on the server.
- Make the service listen on 0.0.0.0 (or the right interface) if it must accept remote connections.
- In Docker, connect by service name or host.docker.internal instead of localhost.
Got a different message? Paste it into the error explainer.
Related errors
- requests.exceptions.ConnectTimeout · Python couldn't open the connection in time
- java.net.ConnectException: Connection refused · Nothing is listening on that port
- dial tcp: i/o timeout · Go couldn't connect in time
- A connection attempt failed because the connected party did not properly respond after a period of time · The connection timed out
- No connection could be made because the target machine actively refused it · Nothing is listening on that port
- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed · Python couldn't verify the server's certificate
- certificate verify failed: Hostname mismatch, certificate is not valid for · The certificate doesn't cover this hostname
- Max retries exceeded with url · requests gave up connecting to the URL
- socket.gaierror: [Errno -2] Name or service not known · Python couldn't resolve the hostname
- socket.gaierror: [Errno -3] Temporary failure in name resolution · Python couldn't reach a DNS resolver
- requests.exceptions.ReadTimeout · The server took too long to respond
- http.client.RemoteDisconnected: Remote end closed connection without response · The server closed the connection without replying