ConnectionRefusedError Python Origin: Application & API Last updated 12 Oct 2026

ConnectionRefusedError: [Errno 111] Connection refused

Nothing is listening on the host/port Python tried to connect to.

Exact message you may see Connection refused[WinError 10061]
Seen on: Python

Meaning

The target service (database, Redis, API) is down, on another port, or — in Docker — you’re connecting to localhost inside a container.

Common causes

  • Target service not running
  • Wrong port
  • localhost inside Docker
  • Service listening only on 127.0.0.1 while connecting remotely

⚡ Quick fix

  1. Start the service and check its port
  2. Use the compose service name as host
  3. Bind the service to 0.0.0.0 when accessed remotely

Detailed fix by platform

Python

  1. Retry with backoff on startup while dependencies come up

How to diagnose

  1. Target — host:port in the traceback
  2. Service — Running?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0x80070035 — 0x80070035: The network path was not found (System error 53) (Windows)0x800700350x80072EE7 — Error 0x80072EE7 (Windows Update / Microsoft Store: server name could not be resolved) (Windows)0x80072EE70x8024402C — Windows Update error 0x8024402C (cannot connect to update server) (Windows)0x8024402C14 UNAVAILABLE — gRPC Error: 14 UNAVAILABLE: No connection established / failed to connect to all addresses (API)14 UNAVAILABLE511 — HTTP 511 Network Authentication Required (HTTP)511521 — Cloudflare Error 521: Web Server Is Down (Cloudflare)521auth/network-request-failed — Firebase Auth: auth/network-request-failed — A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred (Authentication)auth/network-request-…broadcast error — ValueError: operands could not be broadcast together with shapes (3,) (4,) (Python)broadcast errorConnectio…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.