PHP Fatal Error: Cannot Declare Class WP_Metadata_Lazyloader — Fix Guide
Seeing “PHP Fatal error: Cannot declare class WP_Metadata_Lazyloader, because the name is already in use” after upgrading WordPress to 6.3? This guide explains what causes the error and walks through the fix step by step. It typically appears during a WordPress version migration from 6.2.2 to 6.3, in your site’s error log or as a white screen on both the frontend and wp-admin.
The full error usually looks like this:
“PHP Fatal error: Cannot declare class WP_Metadata_Lazyloader, because the name is already in use in /home/xxxx/public_html/wp-includes/class-wp-metadata-lazyloader.php on line 32”
What Causes This Error?
The error means WordPress is loading the WP_Metadata_Lazyloader class definition twice. PHP does not allow the same class to be declared two times in one request, so the process terminates with a fatal error.
In practice this happens when the WordPress 6.3 upgrade is incomplete or partial — core files from 6.2.2 and 6.3 end up mixed in the same installation. Specifically:
- The class file
class-wp-metadata-lazyloader.phpisrequired more than once, or - Autoload and manual-require paths in
wp-settings.phpboth load the same class file.
The WordPress core team tracked this issue in ticket #59057 on WordPress Trac.
How to Fix It: Step by Step
Step 1 — Check wp-settings.php Line 191
Open wp-settings.php in your WordPress root folder and look at around line 191. If you find a manual require of “class-wp-metadata-lazyloader.php”** there, it means the 6.3 upgrade was applied incorrectly — that line should not exist in a clean 6.3 install.
Step 2 — Back Up Your Files
Before changing anything, create a full backup. Use FTP/SFTP or your hosting file manager and copy the site root (at minimum: wp-settings.php, wp-includes/, wp-admin/).
Step 3 — Replace wp-settings.php With a Clean Copy
Download fresh WordPress core files from wordpress.org/download/, then manually replace the wp-settings.php file in your root folder with the one from the download. This removes the duplicated require and usually restores access to both the site and wp-admin immediately.
Step 4 — Reinstall WordPress 6.3 Properly
- Grant write permissions to the
wp-adminfolder (for example 755). - Log in to the admin panel and run the update to 6.3 again (Dashboard → Updates → Re-install version 6.3).
- When the reinstall finishes, verify the site and admin both work.
- Revert the
wp-adminfolder permissions to read-only.
Step 5 — If the Entry Is Missing (Opposite Scenario)
If step 1 found no “class-wp-metadata-lazyloader.php” entry in wp-settings.php but the error still occurs, apply the official patch from the WordPress core team: wordpress-develop PR #4992.
How to Prevent This in Future Upgrades
- Never interrupt a WordPress update — a stopped upgrade is the most common cause of mixed core files.
- Take a backup before upgrading (files + database), so rollback is quick.
- Prefer one-click admin updates or WP-CLI (
wp core update) over manually uploading individual core files. - After any update, check Tools → Site Health for verification that core files match the release.
- Staging first: test major version upgrades on a staging copy before applying to production.
Still Stuck?
If the error persists after these steps, the installation may have deeper file corruption. Contact Cognic — our team fixes WordPress migration failures, broken upgrades, and hosting-level PHP issues regularly, and can restore your site quickly.
Frequently Asked Questions
Common questions about the WP_Metadata_Lazyloader fatal error:
