How to fix a 404 error on WordPress?
Picture this: you have just clicked on a promising link, eagerly anticipating valuable content, only to be greeted by a stark white page with the dreaded words “404 Page Not Found.” Frustrating, isn’t it? In real life, it is like driving to your favorite coffee shop only to discover it has vanished into thin air.
But here is the good news: this frustrating error is almost always fixable, and with the right knowledge, you can prevent it from happening again. Welcome to your complete guide to understanding, fixing, and preventing 404 errors in WordPress.
What Exactly Is a 404 Error?
A 404 error is an HTTP status code that means “Not Found.” It occurs when a web server cannot locate the specific page or resource you are requesting at the given URL. Whether you are seeing “404 Not Found,” “Page Not Found,” “HTTP 404,” or “404 File or Directory Not Found,” they all mean the same thing: the page you are looking for simply does not exist at that address.
Now that we understand what we are dealing with, let us explore why these errors happen in the first place.
10 Common Causes of 404 Errors
1. URL Typos and Mistakes
Sometimes the simplest explanation is the correct one. A misplaced letter or character in a URL can trigger a 404 error faster than you can blink. This applies to both manual URL entry and internal links on your website. For instance, linking to “get-in-toud” instead of “get-in-touch” will inevitably lead to a dead end.
2. Deleted Pages and Posts
Whether by accident or intention, when you delete a page or post without setting up proper redirects, anyone trying to access that URL will encounter a 404. This is particularly common when spring cleaning your content or removing outdated information.
3. Permalink Structure Changes
WordPress allows you to customize your permalink structure. But when you change it – say, from /?p=123 to /%postname%/ – existing URLs shift, and without proper handling, visitors will find nothing but errors.
4. Corrupted .htaccess Files
The .htaccess file serves as your server’s instruction manual for handling URLs. If this file becomes corrupted, damaged, or goes missing, your URL rewriting rules can break entirely, sending your entire site into a 404 spiral.
5. Plugin or Theme Conflicts
Not all WordPress plugins play nicely together. Sometimes, a newly installed or updated plugin can interfere with how WordPress generates URLs and permalinks, triggering widespread 404 errors. The same applies to themes that introduce incompatible code.
6. Server or Hosting Issues
Sometimes the problem is not with WordPress at all. Server misconfigurations, exhausted resources (CPU or memory limits), file permission problems, or temporary server outages can all produce 404 errors.
7. Caching Problems
Caching is a double-edged sword. While it dramatically speeds up your site, outdated caches at the browser, CDN, or server level can serve old 404 responses even after you have fixed the underlying issue.
8. DNS Propagation Delays
For recently registered or transferred domains, DNS changes can take anywhere from a few minutes to 48 hours to propagate globally. During this window, users in certain locations may encounter 404 errors until their local DNS servers catch up.
9. Hacked or Compromised Websites
If your website has been hacked, attackers may generate thousands of spammy URLs that do not actually exist, flooding your Search Console with 404 errors. Even after cleaning up, the residual 404 errors can linger for months.
10. Broken External Backlinks
When other websites link to pages on your site that no longer exist, those links become broken. While you cannot control what others do, these external broken links still affect user experience and waste Google’s crawl budget.
8 Proven Solutions to Fix 404 Errors
Solution 1: Reset Your Permalinks
This is the first line of defense and often works like magic. Here is how to do it:
From the WordPress Dashboard:
- Navigate to Settings → Permalinks
- You do not need to change anything – just click the “Save Changes” button at the bottom
- This refreshes your permalink structure and regenerates rewrite rules
If You Cannot Access the Dashboard:
- Connect to your site via FTP or your hosting file manager
- Navigate to the root directory (public_html)
- Locate and rename the
.htaccessfile to.htaccess_backup - Create a new
.htaccessfile with the default WordPress code (see below)
Solution 2: Fix or Recreate the .htaccess File
Since the .htaccess file controls URL rewriting, repairing or recreating it can resolve many 404 issues.
Step-by-Step Process:
- Connect via FTP or file manager
- Navigate to your root directory
- If
.htaccessexists, download a backup copy to your computer - Open the file and replace its contents with WordPress default code:
# 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- Save the file and test your site
Pro Tip: If you use a multisite WordPress installation, you will need a slightly different .htaccess configuration. The WordPress Codex provides the correct code for multisite networks.
Solution 3: Set Up Proper Redirects
When you have moved or renamed pages, redirects ensure visitors and search engines find the new location. But remember this crucial advice: never redirect all 404 pages to your homepage.
Why Redirecting Everything to Homepage Is Bad Practice:
- Confuses search engines about which content is actually relevant
- Wastes your site’s crawl budget
- Provides a poor user experience
- Can be interpreted as a “soft 404” by Google
The Right Approach to Redirects:
Using the Redirection Plugin:
- Install and activate “Redirection” (2+ million active installations)
- Go to Tools → Redirection and complete the setup
- In the “Source URL” field, enter the old URL that returns a 404
- In the “Target URL” field, enter the new, relevant page URL
- Click “Add Redirect”
Manual Redirect via .htaccess:
Redirect 301 /old-page/ http://webkeepy.com/new-page/When NOT to Redirect:
- If the page was deleted intentionally and has no relevant replacement
- If the content is outdated and you do not want it indexed
- If you are unsure about the new destination’s relevance
Best Practice: Only redirect pages that have a genuinely related destination. Content relevance is key.
Solution 4: Audit Plugins and Themes
Themes and plugins can cause compatibility issues that break URL structures.
Testing Plugins:
- Go to Plugins → Installed Plugins
- Deactivate all plugins at once
- Check if the 404 error persists
- If the error disappears, reactivate plugins one by one
- Test your site after each reactivation to identify the culprit
Testing Themes:
- Navigate to Appearance → Themes
- Temporarily switch to a default WordPress theme (like Twenty Twenty-Four)
- Check if the 404 error resolves
- If yes, the issue is likely your current theme
Cannot Access the Dashboard?
Use FTP to rename the plugins folder to plugins_disabled, which deactivates all plugins. Similarly, rename your active theme folder to force WordPress to fall back to a default theme.
Solution 5: Clear ALL Caches
After fixing the underlying issue, old caches can still serve 404 responses.
Cache Checklist:
- WordPress Cache Plugins: Clear WP Rocket, W3 Total Cache, LiteSpeed Cache, etc.
- Server Cache: Check your hosting control panel for cache clearing options
- CDN Cache: Log into Cloudflare, go to “Caching” → “Configuration” → click “Purge Everything”
- Browser Cache: Clear your browser cache or test in incognito/private mode
Solution 6: Restore Deleted Pages
Sometimes the simplest solution is to bring back what was lost.
Check Your Trash:
- Go to Pages → All Pages
- Click the “Trash” tab
- Find the deleted page you need
- Click “Restore”
Solution 7: Recover from a Hacked Website
If your site has been compromised, follow this cleanup protocol:
- Scan Your Site: Install and run Wordfence or another security plugin for a thorough scan
- Clean the Infection: Follow the plugin’s recommendations to remove malicious code
- Reset Everything: Update all passwords (WordPress admin, FTP, database)
- Update Core and Plugins: Ensure everything is running the latest versions
- Resubmit Your Sitemap: Use Yoast SEO or Rank Math to regenerate and submit your sitemap
- Be Patient: Hacked-site 404 errors will gradually decrease over several months
Solution 8: Contact Your Hosting Provider
When you have exhausted all other options, it is time to call in reinforcements.
Questions to Ask Your Host:
- Are there server misconfigurations affecting URL handling?
- Are file permissions set correctly?
- Are there server-side caching issues?
- Is the PHP memory limit or execution time too low?
- Are there security restrictions blocking legitimate requests?
Your hosting provider’s support team is equipped to diagnose and resolve server-level issues that you cannot access directly.
Understanding the SEO Impact of 404 Errors
Here is a truth that might surprise you: a 404 error itself will not get your website penalized by Google. Google’s Search Advocate, John Mueller, has stated that 404 errors are a normal part of the web, and they do not automatically hurt your rankings.
However, 404 errors carry significant indirect costs:
Link Equity Loss
Imagine a page that has accumulated 15 high-quality backlinks over three years. If that page returns a 404, all that link equity – the SEO value passed through those links – evaporates. Those domains cannot simply transfer their authority elsewhere.
Crawl Budget Drainage
Google allocates a limited number of crawl requests per day for each website. When a significant portion of those requests return 404s, Google will reduce your site’s crawl capacity. This means new or updated content gets discovered and indexed more slowly.
User Experience Degradation
Every 404 page a visitor encounters is a friction point. A poor experience may lead to higher bounce rates, signaling to search engines that your site might not be meeting visitor needs.
Soft 404 Errors
A “soft 404” is when a page returns a 200 OK status (success) but displays a “page not found” message. This is worse than a real 404 because it misleads search engines and wastes crawl budget. Always ensure your 404 pages return a genuine 404 status code.
Index Dilution
If you have multiple URLs pointing to the same nonexistent content through redirects or soft 404s, you may be “diluting” your site’s indexing signals, making it harder for search engines to understand your site’s structure.
410 Status: A Better Alternative to 404
When content is permanently gone and will never return, consider using the 410 Gone status code instead of 404.
Why 410 Is Superior
| Status | Meaning | Google Behavior |
|---|---|---|
| 404 | Not Found (temporary or permanent unknown) | Continues to retry crawling periodically |
| 410 | Gone (permanently removed) | Removes from index more quickly |
Google treats 410 as a clear signal that the page was intentionally and permanently removed. This accelerates URL removal from search results, which is beneficial for maintaining a clean, accurate index.
Setting Up 410 Status in WordPress
- Some premium SEO plugins (like Yoast SEO Premium) allow you to set 410 status
- You can manually return 410 via custom code in your theme’s
functions.php - The Redirection plugin supports redirecting to a 410 status
How to Monitor and Prevent 404 Errors
Proactive Monitoring Tools
Google Search Console (Free):
- Go to “Indexing” → “Pages”
- Look for the “Not found (404)” section
- Click on the issue to see specific URLs and their referring pages
- The “Referring Page” column shows which page contains the broken link
Dedicated WordPress Plugins:
- Redirection: Logs all 404 errors and displays them in a clean interface
- 404 to 301: Monitors and manages 404 errors
- Broken Link Checker: Scans for broken links and notifies you
Third-Party Tools:
- Screaming Frog SEO Spider: Crawls your entire site and identifies broken links
- Ahrefs or SEMrush: Regular site audits that include broken link detection
Prevention Best Practices
- Update Permalinks Carefully
If you change your permalink structure, ensure you have redirects in place. Using a plugin like “Permalink Manager” can help manage transitions. - Set Redirects Immediately
When you delete or move a page, do not delay – set up your redirects instantly. Waiting increases the chance of forgetting and letting errors accumulate. - Keep Everything Updated
Regularly update WordPress core, plugins, and themes. Many 404 errors stem from compatibility issues that updates can prevent. - Conduct Regular Site Audits
Schedule monthly audits of your website’s links. A little prevention beats extensive correction every time. - Be Careful with Sitemaps
Your sitemap should never include URLs that return 404. If you delete a page, update your sitemap immediately. - Use Smart Redirect Plugins
Plugins like “PathCatch” can automatically detect when you change a post’s slug and create a 301 redirect for you. - Educate Your Team
If multiple people manage your site, ensure everyone understands the importance of setting redirects when moving or deleting content.
Creating a Custom 404 Page
A well-designed custom 404 page can transform a frustrating dead end into an opportunity to engage visitors and keep them on your site.
Elements of an Effective 404 Page
Brand Consistency
Use your site’s colors, fonts, logo, and overall design aesthetic. Visitors should immediately recognize they are still on your website, even if they have hit a dead end.
Helpful, Friendly Copy
Avoid technical jargon. Instead use warm, approachable language:
- “Oops! Looks like this page took a wrong turn.”
- “We could not find what you were looking for.”
- “Do not worry – let us get you back on track.”
Clear Navigation Options
Provide multiple pathways back to useful content:
- Search box: The most helpful element for users who know what they want
- “Back to Homepage” button: A clear escape route
- “Popular Posts” or “Recent Posts” section: Keeps visitors engaged
- Sitemap link: For users willing to browse
Visual Appeal
Add personality with animated 404 numbers, custom illustrations, or a touch of humor (if appropriate for your brand).
How to Create a Custom 404 Page in WordPress
Block Themes:
Use the Site Editor to create and design your 404 template.
Page Builders:
Elementor, Divi, and Beaver Builder all support custom 404 page design.
Traditional Themes:
Edit the 404.php file in your theme directory. Here is a simple starting point:
<?php get_header(); ?>
<div class="error-404">
<h1>Oops! Page Not Found</h1>
<p>We could not find the page you were looking for.</p>
<?php get_search_form(); ?>
<a href="<?php echo home_url(); ?>" class="button">Back to Homepage</a>
</div>
<?php get_footer(); ?>Troubleshooting Flowchart
Follow this logical sequence when tackling a 404 error:
Step 1: Verify the URL for typos → Fix if found
Step 2: Reset permalinks → Save Changes
Step 3: Check and repair .htaccess file
Step 4: Deactivate all plugins → Test → Reactivate one by one
Step 5: Switch to default WordPress theme
Step 6: Clear all caches (browser → CDN → server)
Step 7: Check file permissions and server logs
Step 8: Contact hosting provider
FAQ: Your 404 Questions Answered
Q: Should I redirect all my 404 pages to the homepage?
A: Absolutely not. This is a harmful practice that confuses both users and search engines. Only redirect pages that have a genuinely relevant destination. If a page is permanently gone, let it return a 404 or 410 status.
Q: Will 404 errors hurt my SEO?
A: A few 404 errors will not hurt. However, hundreds or thousands of 404s will waste crawl budget and potentially harm user experience. The key is not the number of 404s but whether they represent important, linked-to content.
Q: What if a page was deleted and now shows 404 in Search Console?
A: If the page truly no longer exists and has no relevant replacement, do nothing. Google will eventually remove it from its index. If the page was deleted by mistake, restore it.
Q: How do I handle URL changes for a post or page?
A: Set up a 301 redirect from the old URL to the new URL. Use the Redirection plugin or a manual .htaccess redirect.
Q: Can I add a noindex tag to a 404 page?
A: No. This does not make sense. A noindex tag tells search engines not to index a page that exists. A 404 page does not exist – it is a status code, not a real page you can add tags to.
Q: How long should I keep redirects for moved content?
A: At least one year. Ideally, you should keep redirects permanently unless there is a compelling reason to remove them.
Q: What should I do if a page is deleted but I want to bring it back?
A: Simply recreate the page with the same URL. Add content similar to what was there before. Search engines will index it normally, just as if it never left.
Q: My 404 errors appeared after a hack. What should I do?
A: Clean your site with Wordfence, update everything, and be patient. The errors will gradually decrease as search engines recrawl your site. Resubmit your sitemap to speed up the process.
Q: What about AMP (Accelerated Mobile Pages) 404 errors?
A: If you have removed AMP from your site or disabled AMP pages, leave the 404 errors be. They will resolve naturally as Google processes the 404 status.
Q: How can I identify which page contains a broken link?
A: In Google Search Console, click on a 404 URL and look at “Referring Page.” This shows exactly which page on your site is linking to the broken URL.
Q: Can my CDN cause 404 errors?
A: Yes. A CDN can cache 404 responses. Even after fixing the source, users may still see cached 404s. Always clear your CDN cache after making changes.
Q: How long does it take for Google to re-crawl a fixed 404 page?
A: It depends on your site’s crawl frequency. Smaller sites might see changes in days to weeks. Larger, high-authority sites might see changes within hours. You can manually request re-indexing through Search Console’s URL Inspection tool.
Q: Does the URL structure matter for preventing 404 errors?
A: Yes. Using descriptive, human-readable URLs instead of numeric or cryptic ones reduces the chance of user typos and makes it easier to set up logical redirects when content moves.
Q: How do I manage multiple 404s from a site migration?
A: Create a complete URL map of old URLs to new URLs before the migration. Use a tool or plugin to set up mass redirects. Test thoroughly after the migration.
Q: What is the difference between a 301 and 302 redirect for 404s?
A: 301 indicates a permanent move and passes full link equity. 302 is temporary and does not pass full link equity. For moved content, always use 301 redirects.
Q: If I have a 404 error on a URL with incoming backlinks, should I redirect it?
A: Yes, if you have a relevant page to redirect to. Redirecting preserves the link equity from those backlinks. If you do not have a relevant page, consider creating one.
Q: What if the referring page for a 404 error is also not available?
A: Investigate why the referring page was deleted. If it was a mistake, restore it. If it was moved, set up a 301 redirect. If it was intentionally deleted, the issue becomes a self-resolving broken link chain that does not require intervention.
Conclusion: Taking Control of 404 Errors
404 errors are an inevitable reality of website management. They can be frustrating to encounter, but they are entirely manageable with the right approach.
Remember these key takeaways:
Fix First: Start with the simplest solutions – resetting permalinks is usually your best bet. Work your way through the troubleshooting flow until you resolve the issue.
Redirect Wisely: Never redirect all 404s to your homepage. Only redirect content that has a genuine, relevant new home.
Monitor Continuously: Use Google Search Console and monitoring plugins to catch 404s before they become problems.
Prevent Proactively: Set redirects immediately when deleting or moving content. Keep your site updated and regularly audit your links.
Enhance User Experience: A thoughtful, well-designed custom 404 page can turn an error into an engagement opportunity.
Understand SEO Impact: 404 errors do not directly penalize you, but they have indirect costs through link equity loss and crawl budget waste.
By implementing the strategies outlined in this guide, you will be well-equipped to handle any 404 error that comes your way. More importantly, you will have the knowledge to prevent many of them from occurring in the first place.
The journey to a smoother, more user-friendly website starts with understanding and mastering these HTTP errors. Take control of your 404s today, and give your visitors – and search engines – the experience they deserve.
