📝 WordPress: Fix Permalinks 404ing After Switching PHP Versions
Pretty permalinks depend on the web server correctly rewriting every request to index.php, and on many managed hosts that rewrite logic is tied to a specific PHP-FPM pool socket baked into the vhost configuration. Switching a site’s PHP version from the hosting control panel can silently leave the web server’s own config pointed at the old PHP-FPM socket – the panel updates its displayed version label, but nothing forces the underlying fastcgi_pass or proxy directive to follow – so PHP itself keeps running fine while every URL except the literal homepage starts returning a 404.
🔎 The Problem
# vhost before the PHP version switch fastcgi_pass unix:/run/php/php7.4-fpm.sock; # vhost after switching PHP version in the hosting control panel # (the panel updated its displayed version label, not this line) fastcgi_pass unix:/run/php/php7.4-fpm.sock; # still the old socket # php8.3-fpm pool is now running; the php7.4-fpm socket is gone -> # every rewritten URL (anything but the literal homepage) -> 404
✅ Fix: Resave Permalinks and Confirm the Socket Actually Changed
- After changing the PHP version, go to Settings > Permalinks in wp-admin and click Save without changing anything – this forces WordPress to regenerate its rewrite rules against the currently active PHP handler.
- If the host manages the web server config outside wp-admin, check that its
fastcgi_passorproxy_passsocket path actually points at the new PHP version’s socket, not just that the panel’s version label changed. - Clear any full-page cache after resaving permalinks, since a cached 404 response for a URL can keep being served even after the rewrite rule itself is fixed.
🚨 Why This Is Dangerous
- Assuming a PHP version switch only affects execution speed, not rewrite routing, can leave a site silently 404ing on every post and page for hours while both visitors and search crawlers hit the broken URLs.
A PHP version switch moves which socket serves your site – if nothing told the web server’s rewrite rules, they’re still pointed at the one that’s gone.
