panic: send on closed channel Go Origin: Application & API OSI layer 7 · Application Last updated 4 Nov 2026

Go: panic: send on closed channel

A goroutine sent a value to a channel after it had been closed.

Exact message you may see panic: send on closed channelsend on closed channelpanic: send on closed channel goroutine
Seen on: Go

Meaning

Only the sender (or a single coordinating owner) should close a channel, never the receiver, and never while other goroutines might still send. Use a sync.WaitGroup to wait for all senders before closing, or signal shutdown with a separate done channel/context.

Common causes

  • Closing from the receiver side
  • Multiple senders and one closes early
  • Close before all senders finish
  • Shutdown path racing with producers
  • Reusing a closed channel

⚡ Quick fix

  1. Let the producer close after all sends finished
  2. wg.Wait(); close(ch) in a coordinator goroutine
  3. Use context.Context for cancellation instead of closing a shared channel

Detailed fix by platform

Go

  1. go func(){ wg.Wait(); close(results) }()

How to diagnose

  1. Owner — Who closes?
  2. Senders — Still running?
  3. Signal — Use context?

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

all goroutines are asleep - deadlock — Go: fatal error: all goroutines are asleep - deadlock! (Go)all goroutines are as…context canceled — Go: context canceled (rpc error: code = Canceled desc = context canceled) (Go)context canceledfatal error: concurrent map read and map write — Go: fatal error: concurrent map read and map write (Go)fatal error: concurre…fatal error: concurrent map writes — Go: fatal error: concurrent map writes (Go)fatal error: concurre…listen tcp :8080: bind: address already in use — Go: listen tcp :8080: bind: address already in use (Go)listen tcp :8080: bin…panic: close of closed channel — Go: panic: close of closed channel (or close of nil channel) (Go)panic: close of close…panic: sync: negative WaitGroup counter — Go: panic: sync: negative WaitGroup counter (Go)panic: sync: negative…WARNING: DATA RACE — Go: WARNING: DATA RACE — Write at 0x00c0000 by goroutine 7: / Previous read at ... by goroutine 6 (Go)WARNING: DATA RACEpanic: se…

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.