Fatal error: Maximum function nesting level of '256' reached, aborting!
Recursion went deeper than Xdebug’s max_nesting_level allows (or PHP crashed with a segfault without Xdebug).
Maximum function nesting level Meaning
The message comes from Xdebug. Without Xdebug, infinite recursion in PHP usually ends in a segmentation fault or memory exhaustion.
Common causes
- Infinite recursion (missing base case)
- Magic methods calling themselves (__get inside __get)
- Legitimately deep recursion on big trees
⚡ Quick fix
- Find the repeating frames in the trace
- Fix the base case
- Raise
xdebug.max_nesting_levelonly for legitimately deep recursion
Detailed fix by platform
PHP
- Convert deep recursion to an iterative loop with an explicit stack
How to diagnose
- Frames — Which function repeats?
- Base case — Is it ever reached?
🔧 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
- Allowed memory size exhausted PHP Fatal error: Allowed memory size of X bytes exhausted
- ArgumentCountError Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 1 passed and exactly 2 expected
- Call to member function on null Fatal error: Uncaught Error: Call to a member function x() on null
Most viewed in PHP
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 12 Oct 2026