What Is the WordPress 404 Page Not Found Error?
A WordPress 404 error means the server can’t find the page you’re trying to access. You’ll see messages like:
- “404 Not Found”
- “The page you are looking for doesn’t exist”
- “Oops! That page can’t be found”
Unlike other errors, 404s don’t mean your site is broken. They simply indicate that WordPress doesn’t know how to route the URL you requested. This commonly happens after changing permalink settings, migrating your site, or when WordPress’s URL rewrite rules stop working properly.
The homepage might load perfectly while all other pages—posts, categories, custom post types—return 404 errors. This is the most telling symptom that your permalink structure has broken.
Common Causes of 404 Errors
- Corrupted .htaccess file — Rewrite rules are missing or damaged
- Permalink settings changed — You modified URL structure without regenerating rules
- Site migration issues — Moving sites breaks URL configurations
- Plugin conflicts — SEO or caching plugins interfering with URL routing
- Missing index.php — WordPress’s main routing file was deleted
- Incorrect file permissions — WordPress can’t read/write .htaccess
- Server configuration issues — mod_rewrite module disabled on Apache
- Custom post type registration — Custom URLs not flushed after adding new post types
Solution 1: Reset Permalinks (Fixes 80% of Cases)
This is the fastest fix and resolves most 404 errors instantly.
- Log in to WordPress admin (
yoursite.com/wp-admin) - Go to Settings → Permalinks
- Note your current permalink structure (you’ll set it back)
- Click on “Plain” temporarily
- Click “Save Changes”
- Now select your original structure (usually “Post name”)
- Click “Save Changes” again
WordPress regenerates the .htaccess rewrite rules. Test your site—404 errors should be gone.
Why this works: WordPress rewrites URLs internally but stores routing rules in .htaccess. When these rules get corrupted or deleted, WordPress can’t match URLs to content. Resaving permalinks regenerates clean rules.
Solution 2: Manually Check and Fix .htaccess
If resetting permalinks doesn’t work, the .htaccess file might be corrupted or missing.
Via FTP:
- Connect to your site via FTP
- Navigate to your WordPress root directory
- Look for
.htaccess(enable “Show hidden files” in your FTP client) - Download a backup copy to your computer
If .htaccess exists but is corrupted:
Delete it and create a new one with this default WordPress content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If .htaccess is missing:
Create it via FTP and add the code above. Then go to WordPress admin → Settings → Permalinks → Save Changes to finalize.
Solution 3: Check File Permissions on .htaccess
WordPress needs proper permissions to read and write .htaccess.
Correct permissions:
.htaccessfile: 644
Via FTP:
- Right-click
.htaccess - Select “File Permissions” or “Change Permissions”
- Enter
644or check: Owner (Read, Write), Group (Read), Public (Read) - Click OK
Via SSH:
cd /home/username/public_html
chmod 644 .htaccess
After fixing permissions, go to Settings → Permalinks → Save Changes to regenerate rules.
Solution 4: Enable mod_rewrite on Apache
WordPress permalinks require the Apache mod_rewrite module. If it’s disabled, all pages except the homepage will show 404 errors.
Check if mod_rewrite is enabled:
Create a file named test-rewrite.php:
<?php
if (in_array('mod_rewrite', apache_get_modules())) {
echo "mod_rewrite is enabled";
} else {
echo "mod_rewrite is NOT enabled";
}
?>
Visit yoursite.com/test-rewrite.php. If it says “NOT enabled,” contact your hosting provider to enable it.
On your own server (VPS/dedicated):
sudo a2enmod rewrite
sudo systemctl restart apache2
Delete test-rewrite.php after testing.
Solution 5: Check WordPress Address Settings
Incorrect site URL settings cause 404 errors on all pages.
- Go to Settings → General
- Check “WordPress Address (URL)” and “Site Address (URL)”
- Both should match, usually:
https://yourdomain.com(or with www if you use it)
- If they’re different or wrong, update them
- Click “Save Changes”
Can’t access wp-admin? Edit via database:
- Access phpMyAdmin from cPanel
- Select your WordPress database
- Open the
wp_optionstable - Find row with
option_name=siteurl - Update
option_valueto your correct site URL - Do the same for
option_name=home
Solution 6: Flush Rewrite Rules via Code
If the permalink reset doesn’t work through the dashboard, force it via code.
Method 1: Add to theme’s functions.php temporarily:
function custom_flush_rewrite_rules() {
flush_rewrite_rules();
}
add_action('init', 'custom_flush_rewrite_rules');
Visit your site once, then remove this code immediately. Don’t leave it—flushing on every page load impacts performance.
Method 2: Via wp-cli (if available):
wp rewrite flush
This is the cleanest method if you have SSH access and wp-cli installed.
Solution 7: Disable Plugins Temporarily
A plugin might be interfering with WordPress’s URL routing.
Via WordPress admin:
- Go to Plugins → Installed Plugins
- Deactivate all plugins
- Test your site
- If 404s disappear, reactivate plugins one by one to find the culprit
Via FTP (if locked out):
- Navigate to
/wp-content/plugins/ - Rename
pluginsfolder toplugins-disabled - Test your site
- If it works, rename back to
pluginsand test individual plugins
Common plugin culprits:
- SEO plugins (Yoast, Rank Math) with broken rewrite rules
- Caching plugins with aggressive settings
- Custom post type plugins not registering URLs properly
Solution 8: Switch to Default Theme
Theme conflicts can cause 404 errors, especially with custom post types.
Via WordPress admin:
- Go to Appearance → Themes
- Activate a default WordPress theme (Twenty Twenty-Three, etc.)
- Test your site
Via FTP:
- Navigate to
/wp-content/themes/ - Rename your active theme folder (e.g.,
mytheme→mytheme-disabled) - WordPress automatically activates a default theme
If 404s disappear, your theme has a routing conflict. Contact the theme developer.
Solution 9: Check Custom Post Type Registration
If only custom post types return 404 errors, their rewrite rules weren’t registered properly.
Add this to your theme’s functions.php or custom post type plugin:
function fix_custom_post_type_permalinks() {
// Replace 'my_custom_post_type' with your actual post type slug
$post_type = 'my_custom_post_type';
if (post_type_exists($post_type)) {
flush_rewrite_rules(false);
}
}
add_action('init', 'fix_custom_post_type_permalinks');
Visit your site once, then remove this code. Better yet, use this command if you have wp-cli:
wp rewrite flush --hard
Solution 10: Check Nginx Configuration (If Not Using Apache)
If your server runs Nginx instead of Apache, .htaccess doesn’t work. You need Nginx rewrite rules.
Add this to your Nginx configuration file (usually at /etc/nginx/sites-available/yourdomain):
location / {
try_files $uri $uri/ /index.php?$args;
}
Then reload Nginx:
sudo systemctl reload nginx
Contact your hosting provider if you don’t have access to Nginx configs.
Prevention Tips
- Don’t manually edit .htaccess unless necessary
- Always flush permalinks after adding custom post types
- Keep backup copies of working .htaccess files
- Test theme and plugin updates on staging before production
- Verify site URLs are correct after migrations
- Use version control to track .htaccess changes
- Document any custom rewrite rules you add
Personal note: I keep a “last known good” copy of .htaccess saved locally for every site I manage. When 404s pop up unexpectedly, I can compare the current version to my backup and spot exactly what changed. This has saved me hours of debugging over the years.
Related: If you’re experiencing other WordPress errors alongside 404s, check How to Fix WordPress 500 Internal Server Error or How to Fix WordPress 403 Forbidden Error for additional troubleshooting methods.
Conclusion
WordPress 404 errors almost always come from broken permalink settings or corrupted .htaccess files. The fix is usually just a matter of going to Settings → Permalinks and clicking Save Changes. If that doesn’t work, regenerating a clean .htaccess file solves the issue 95% of the time. The important thing is understanding that 404s don’t mean your content is gone—WordPress just lost the routing map and needs you to regenerate it.