Go: runtime: goroutine stack exceeds 1000000000-byte limit — fatal error: stack overflow
Unbounded recursion consumed the goroutine's stack until it hit the 1 GB limit.
runtime: goroutine stack exceeds 1000000000-byte limitfatal error: stack overflowgoroutine stack exceeds 1000000000-byte limitruntime: sp= stack=[ ] fatal error: stack overflow Meaning
The stack trace repeats the same function many times. Add a base case, convert deep recursion to iteration, or break accidental infinite recursion such as a String() method that formats itself, or MarshalJSON calling json.Marshal on the same type.
Common causes
- Missing or unreachable base case
- String() calling fmt.Sprintf("%v", itself)
- MarshalJSON/UnmarshalJSON recursing into itself
- Cyclic data structures traversed naively
- Mutual recursion
⚡ Quick fix
- Fix the base case
- In String(): convert to a plain type (
type plain T; fmt.Sprintf("%v", plain(t))) - Use a visited set for graphs
Detailed fix by platform
Go
- Look at the top lines of the trace for the repeating function
How to diagnose
- Trace — Same function repeated?
- Method — String/MarshalJSON?
- Base — Exit condition?
🔧 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 4 Nov 2026