PHP error guide

Xdebug already loaded: meaning and fix

Error summary

Keep exactly one zend_extension entry in the effective configuration. More than one scanned ini file loads the same zend_extension.

What it means

Keep exactly one zend_extension entry in the effective configuration. More than one scanned ini file loads the same zend_extension.

What the error means

This message means that more than one scanned ini file loads the same zend_extension. The exact signature distinguishes xdebug already loaded from a generic application failure.

Why PHP produces it

The engine or service reports “Xdebug already loaded” because its required precondition was not met. Keep exactly one zend_extension entry in the effective configuration.

PHP version notes

The xdebug already loaded wording here is based on Xdebug 3.x except the nesting-level legacy page; punctuation and exception class names can differ on older branches or vendor builds.

Most common causes

  • The immediate input or configuration reaches the specific condition: more than one scanned ini file loads the same zend_extension
  • The code path assumes the prerequisite for xdebug already loaded has already been satisfied.
  • For xdebug already loaded, development and production differ in version, extension, permissions, paths, or service configuration.
  • An earlier operation returned an unchecked value that is consumed by the line reporting xdebug already loaded.

Minimal examples

BAD — reproduces the problem

ini
zend_extension=xdebug
zend_extension=xdebug.so

FIXED — safer pattern

ini
zend_extension=xdebug.so

Step-by-step diagnosis

  1. Copy the complete “Cannot load Xdebug - it was already loaded” text and retain the first application stack frame.
  2. Reproduce xdebug already loaded in the same SAPI and environment listed for this page.
  3. Before changing xdebug already loaded, inspect the preceding value or directive and verify its type, path, version, and permissions.
  4. Apply the narrow correction—keep exactly one zend_extension entry in the effective configuration—then repeat the original request once.

Fixes

Correct the failing prerequisite

Keep exactly one zend_extension entry in the effective configuration

ini
zend_extension=xdebug.so

Fail explicitly at the boundary

Validate the condition before the operation that emits xdebug already loaded, and log a safe diagnostic without credentials or full production paths.

Common mistakes when fixing it

  • Suppressing xdebug already loaded instead of correcting its upstream condition.
  • Testing xdebug already loaded only with the CLI binary when the failing request runs under FPM or Apache.
  • Changing a global setting for xdebug already loaded before confirming the site-specific effective configuration.

How to prevent it

  • Add a focused test that exercises the boundary responsible for xdebug already loaded.
  • Keep runtime versions, extensions, configuration, and deploy artifacts affecting xdebug already loaded reproducible.
  • Validate external data and service return values before they can trigger xdebug already loaded.

Web server / environment notes

fpm, cli, docker, linux. The failure occurs where more than one scanned ini file loads the same zend_extension

Tags: fpm,cli,docker,linux

Categories