How does Go's deadlock detection work, and what conditions cause a 'fatal error: all goroutines are asleep' panic?

Last updated 20 June 2026

  • The runtime panics with fatal error: all goroutines are asleep - deadlock! when zero goroutines are runnable, meaning nothing can ever wake them.

  • Common triggers: sending/receiving on an unbuffered channel with no partner, receiving from a channel never written or closed, or all goroutines stuck on WaitGroup.Wait() or an unreleased mutex.

  • It only detects a total global stall. Partial deadlocks, or hangs while a timer or network poller keeps something alive, go undetected.

  • https://github.com/golang/go/issues/59600
  • https://www.geeksforgeeks.org/go-language/golang-deadlock-and-default-case-in-select-statement/
  • https://www.freecodecamp.org/news/learning-go-from-zero-to-hero-d2a3223b3d86/
All Golang interview questions