all goroutines are asleep - deadlock Go Origin: Application & API OSI layer 7 · Application Last updated 14 Oct 2026

Go: fatal error: all goroutines are asleep - deadlock!

Every goroutine is blocked waiting (on a channel, mutex or WaitGroup), so the program can never continue.

Exact message you may see all goroutines are asleep - deadlock!fatal error: all goroutines are asleepgoroutine 1 [chan send]
Seen on: Go

Meaning

Classic causes: sending on an unbuffered channel with no receiver, ranging over a channel that’s never closed, WaitGroup.Wait with Add counts that never reach zero, or locking a mutex twice.

Common causes

  • Send on unbuffered channel without a receiver goroutine
  • range over a channel never closed
  • wg.Add/Done mismatch
  • Mutex locked twice in the same goroutine

⚡ Quick fix

  1. Start the receiver before sending or use a buffered channel
  2. close() channels when producers finish
  3. Match every Add with Done (defer wg.Done())

Detailed fix by platform

Go

  1. go
    ch := make(chan int)
    go func() {
        defer close(ch)
        for i := 0; i < 3; i++ { ch <- i }
    }()
    for v := range ch { fmt.Println(v) }

How to diagnose

  1. Trace — goroutine states (chan send, chan receive, semacquire)
  2. Channels — Who closes them?

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

40001 — ERROR: could not serialize access due to concurrent update (PostgreSQL)40001409 — HTTP 409 Conflict (HTTP)409412 — HTTP 412 Precondition Failed (HTTP)412428 — HTTP 428 Precondition Required (HTTP)428A second operation was started on this context — EF Core: A second operation was started on this context instance before a previous operation completed (.NET)A second operation wa…AnotherOperationInProgress — Conflict: AnotherOperationInProgress — Another operation is in progress on the resource (Azure)AnotherOperationInPro…Collection was modified — InvalidOperationException: Collection was modified; enumeration operation may not execute (.NET)Collection was modifi…concurrent_requests_limit — API Error: Too many concurrent requests (concurrency limit reached) (API)concurrent_requests_l…all gorou…

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.