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.
all goroutines are asleep - deadlock!fatal error: all goroutines are asleepgoroutine 1 [chan send] 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
- Start the receiver before sending or use a buffered channel
- close() channels when producers finish
- Match every Add with Done (defer wg.Done())
Detailed fix by platform
Go
- 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
- Trace — goroutine states (chan send, chan receive, semacquire)
- 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:
Similar errors
Most viewed in Go
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 14 Oct 2026