How to Fix WordPress 404 Error
A 404 Not Found error in WordPress means the requested page or resource cannot be found on the server. Visitors may see messages such as “404 Not Found,” “Page Not Found,” or “The requested URL was not found on this server.”
A WordPress 404 error can affect individual pages, posts, categories, images, or even the entire website. Fortunately, most 404 problems can be fixed without reinstalling WordPress.
This guide explains the common causes of WordPress 404 errors and provides practical solutions.
What Causes a WordPress 404 Error?
Common causes include:
- Incorrect or broken permalink settings
- A corrupted
.htaccessfile - Deleted or moved pages
- Incorrect URLs
- Plugin conflicts
- Theme-related problems
- Incorrect WordPress URL settings
- Missing rewrite rules
- Server configuration problems
- Changes made during website migration
- Broken internal links
Before making changes, it is a good idea to create a backup of your WordPress files and database.
1. Check the URL
Start with the simplest solution: verify that the URL is correct.
For example:
https://example.com/about-us/
Check for:
- Spelling mistakes
- Incorrect capitalization where relevant
- Missing or extra characters
- Incorrect category or post slugs
- Old URLs saved in bookmarks
If the page was recently renamed, the old URL may no longer exist.
2. Refresh WordPress Permalinks
One of the most common causes of WordPress 404 errors is incorrect permalink configuration.
You can refresh the rewrite rules without changing your permalink structure.
Steps
- Log in to the WordPress dashboard.
- Go to Settings → Permalinks.
- Check your current permalink structure.
- Click Save Changes.
You do not need to change the permalink option. Simply saving the settings forces WordPress to regenerate its rewrite rules.
Now open the previously broken URL and check whether it works.
3. Check the .htaccess File
On Apache-based servers, WordPress uses the .htaccess file to handle URL rewriting.
A damaged or incorrect .htaccess file can cause 404 errors.
The default WordPress .htaccess configuration for a standard installation is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
How to regenerate .htaccess
- Connect to your server using File Manager or FTP.
- Locate the WordPress installation directory.
- Enable Show Hidden Files if necessary.
- Find
.htaccess. - Download a backup copy.
- Rename or remove the existing file.
- Log in to WordPress.
- Go to Settings → Permalinks.
- Click Save Changes.
WordPress should generate a new .htaccess file automatically if the server allows it.
Important: If your website contains custom .htaccess rules, back up the file before replacing it.
4. Check Whether the Page Still Exists
If only one or a few URLs return a 404 error, the page may have been deleted or moved.
Go to:
WordPress Dashboard → Pages
or
WordPress Dashboard → Posts
Search for the missing content.
If the page exists, check its permalink or slug.
For example, a page may have changed from:
/services/
to:
/our-services/
In that case, the old URL will return a 404 error.
5. Check the Page Slug
WordPress generates URLs using slugs.
Open the affected post or page and check the Permalink or URL Slug.
For example:
Title: Web Hosting Services
Slug: web-hosting-services
The URL becomes:
https://example.com/web-hosting-services/
Make sure links pointing to the page use the current slug.
6. Check WordPress Address and Site Address
Incorrect WordPress URL settings can cause serious URL problems.
Go to:
Settings → General
Check these two values:
- WordPress Address (URL)
- Site Address (URL)
For example:
WordPress Address: https://example.com
Site Address: https://example.com
Make sure they use the correct:
- Domain name
- HTTPS/HTTP protocol
- Subdirectory, if applicable
Do not change these values unless you know the correct configuration, especially on an existing production website.
7. Temporarily Disable Plugins
A plugin can sometimes modify URLs, rewrite rules, redirects, or custom post types and cause 404 errors.
To test for a plugin conflict:
- Go to Plugins → Installed Plugins.
- Temporarily deactivate the plugins.
- Test the broken URL.
- If the URL works, reactivate plugins one at a time.
- Test the website after activating each plugin.
When the 404 error returns, the last activated plugin is a strong candidate for the problem.
Plugins that commonly affect URLs include:
- SEO plugins
- Redirection plugins
- Security plugins
- Caching plugins
- Custom post type plugins
- Membership plugins
8. Test With a Default WordPress Theme
Your active theme may contain custom rewrite rules or routing code that causes 404 errors.
Temporarily switch to a default WordPress theme.
For example:
Appearance → Themes
Activate a default WordPress theme and test the affected URL.
If the page works afterward, investigate the theme’s:
functions.php- Custom rewrite rules
- Custom post types
- Template files
- Routing logic
Restore your original theme after testing if necessary.
9. Flush Custom Rewrite Rules
If your website uses custom post types or custom taxonomies, their rewrite rules may need to be refreshed.
Go to:
Settings → Permalinks
Then click:
Save Changes
This flushes WordPress rewrite rules.
Developers registering custom post types should also ensure that rewrite settings are correctly configured.
For example:
register_post_type('products', [
'public' => true,
'rewrite' => [
'slug' => 'products'
]
]);
After changing custom post type rewrite settings, refresh the permalink rules.
10. Check for Incorrect Redirects
Redirect plugins, server rules, or CDN configurations can sometimes send visitors to URLs that do not exist.
Review:
- WordPress redirect plugins
.htaccess- Nginx configuration
- CDN rules
- Cloudflare redirect rules
- Domain forwarding rules
Remove outdated or conflicting redirects.
11. Check Server Configuration
If permalink changes do not solve the problem, the issue may be related to your web server.
Apache
Make sure Apache has URL rewriting enabled and that the WordPress directory is allowed to use rewrite rules.
The mod_rewrite module is commonly required.
Nginx
Nginx does not use .htaccess. WordPress requires an appropriate Nginx configuration for pretty permalinks.
A typical configuration includes:
location / {
try_files $uri $uri/ /index.php?$args;
}
After changing Nginx configuration, validate the configuration and reload Nginx.
If you use managed hosting, contact your hosting provider if you do not have access to the server configuration.
12. Clear Caches
Cached 404 responses can sometimes make it appear that the problem still exists after you have fixed it.
Clear caches from:
- WordPress caching plugins
- Server-level caching
- CDN
- Cloudflare
- Browser
Then test the URL in a private/incognito browser window.
13. Check for Broken Internal Links
A website may generate 404 errors because other pages still link to an old URL.
For example:
Old URL:
https://example.com/wordpress-hosting/
New URL:
https://example.com/managed-wordpress-hosting/
Update internal links to point to the new URL.
You can also create a redirect from the old URL to the new one.
14. Create a 301 Redirect for Permanently Moved Pages
If a page has been permanently moved, redirect the old URL instead of leaving visitors with a 404.
For example:
/old-page/
can redirect to:
/new-page/
A 301 redirect tells browsers and search engines that the page has permanently moved.
This is particularly important when changing URLs on an established website because it can help preserve existing search traffic and backlinks.
15. Check Recently Migrated Websites
If the 404 errors appeared after moving WordPress to a new server or domain, check:
- WordPress URL settings
.htaccess- Permalink structure
- Database URLs
- Server rewrite configuration
- DNS settings
- CDN configuration
- File permissions
Always test several posts, pages, categories, and media URLs after a migration.
16. Check File and Directory Permissions
Incorrect permissions can prevent the server from accessing files correctly.
Typical Linux permissions often look like:
Directories: 755
Files: 644
Do not blindly change permissions on an entire server. Check your hosting provider’s recommended WordPress permissions and ownership settings.
17. Check the WordPress Error Logs
If the cause is still unclear, inspect the server and WordPress logs.
Depending on your hosting environment, useful locations may include:
PHP error logs
Apache error logs
Nginx error logs
WordPress debug.log
You can enable WordPress debugging temporarily with:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
The log is typically written to:
/wp-content/debug.log
Disable debugging after troubleshooting on a production website.
18. How to Fix 404 Errors After Changing Permalinks
Changing a permalink structure can cause previously indexed URLs to stop working.
For example:
Old:
/blog/post-name/
New:
/post-name/
The old URL may now return a 404.
To fix this:
- Decide on the correct permalink structure.
- Save the new permalink settings.
- Create redirects from important old URLs.
- Update internal links.
- Check your sitemap.
- Monitor Google Search Console for crawl errors.
Avoid changing URL structures unnecessarily on established websites.
19. How to Fix 404 Errors in WordPress Admin
If WordPress admin URLs themselves are returning 404 errors, the problem may be more serious.
Check:
.htaccess- WordPress URL settings
- Security plugins
- Login URL plugins
- Server rewrite rules
- Recent migrations
- File integrity
If necessary, disable plugins manually through the database or by renaming the plugins directory.
For example:
/wp-content/plugins/
can temporarily be renamed:
/wp-content/plugins-disabled/
If the dashboard becomes accessible, a plugin conflict is likely.
20. How to Prevent WordPress 404 Errors
You can reduce future 404 problems by following good maintenance practices:
- Avoid changing URLs unnecessarily.
- Use descriptive and stable slugs.
- Create redirects when moving pages.
- Regularly check broken links.
- Keep WordPress, themes, and plugins updated.
- Maintain regular backups.
- Test URLs after migrations.
- Monitor crawl errors.
- Keep server rewrite configuration correct.
- Avoid installing unnecessary URL-management plugins.
Quick Troubleshooting Checklist
If your WordPress website suddenly starts showing 404 errors, work through this checklist:
☐ Check the URL
☐ Confirm the page still exists
☐ Check the page slug
☐ Save Settings → Permalinks
☐ Check .htaccess
☐ Check WordPress URL settings
☐ Disable plugins temporarily
☐ Test with a default theme
☐ Clear WordPress/server/CDN caches
☐ Check redirects
☐ Check Apache/Nginx configuration
☐ Review server and WordPress logs
☐ Add 301 redirects for moved pages
Conclusion
A WordPress 404 error usually means that WordPress or the web server cannot locate the requested URL. In many cases, simply resaving the permalink settings fixes the problem. If that does not work, investigate .htaccess, plugins, themes, redirects, server rewrite rules, and recent website changes.
For websites that have recently migrated or changed their URL structure, pay particular attention to permalinks, redirects, and server configuration. Fixing these issues quickly can prevent broken links, poor user experience, and unnecessary SEO problems.