Go: panic: send on closed channel
A goroutine sent a value to a channel after it had been closed.
panic: send on closed channelsend on closed channelpanic: send on closed channel goroutine 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
- Let the producer close after all sends finished
wg.Wait(); close(ch)in a coordinator goroutine- Use
context.Contextfor cancellation instead of closing a shared channel
Detailed fix by platform
Go
go func(){ wg.Wait(); close(results) }()
How to diagnose
- Owner — Who closes?
- Senders — Still running?
- 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:
Similar errors
Most viewed in Go
- invalid memory address or nil pointer dereference Go: panic: runtime error: invalid memory address or nil pointer dereference
- declared and not used Go: declared and not used: x / "fmt" imported and not used
- function main is undeclared in the main package Go: runtime.main_main·f: function main is undeclared in the main package
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 4 Nov 2026