listen tcp :8080: bind: address already in use Go Origin: Application & API OSI layer 4 · Transport Last updated 4 Nov 2026

Go: listen tcp :8080: bind: address already in use

The port your Go server wants is already taken by another process (or a previous instance of your app).

Exact message you may see listen tcp :8080: bind: address already in uselisten tcp 0.0.0.0:8080: bind: address already in usebind: address already in use golisten tcp 127.0.0.1:3000: bind: address already in use
Seen on: Go Linux

Meaning

Find the process with lsof -i :8080 or ss -ltnp, stop it, or choose another port (read from PORT). A crashed dev server or go run child process can stay alive. In containers ensure only one process binds the port.

Common causes

  • Previous instance still running
  • Another service on the same port
  • go run left a child process
  • Port published twice in Docker
  • Hot-reload tool starting two copies

⚡ Quick fix

  1. lsof -i :8080 then kill <pid>
  2. Use a different port via env PORT
  3. Check Docker/compose port mappings

Detailed fix by platform

Linux

  1. ss -ltnp | grep :8080 or lsof -i :8080

How to diagnose

  1. Owner — Which PID?
  2. Port — Configurable?
  3. Docker — Duplicate mapping?

🔧 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):

assignment mismatch: 1 variable but f returns 2 values — Go: assignment mismatch: 1 variable but os.Open returns 2 values (Go)assignment mismatch: …cannot assign to struct field m[k].f in map — Go: cannot assign to struct field users["bob"].Age in map (Go)cannot assign to stru…cannot find package in any of GOROOT / GOPATH — Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH) (Go)cannot find package i…cgo: C compiler gcc not found — Go: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH (Go)cgo: C compiler gcc n…Client.Timeout exceeded while awaiting headers — Go: net/http: request canceled (Client.Timeout exceeded while awaiting headers) (Go)Client.Timeout exceed…context canceled — Go: context canceled (rpc error: code = Canceled desc = context canceled) (Go)context canceledcontext deadline exceeded — Go: Get "https://api.example.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers) (Go)context deadline exce…dial tcp: connect: connection refused — Go: dial tcp 127.0.0.1:5432: connect: connection refused (Go)dial tcp: connect: co…listen tc…

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.