WordPressHow to Fix WordPress 404 Errors: 7 Fixes That Actually Work

How to Fix WordPress 404 Errors: 7 Fixes That Actually Work

How to Fix WordPress 404 Errors: 7 Fixes That Actually Work

Nothing kills a visitor’s trust faster than a dead page. They click a link to your best blog post or your pricing page and get a cold “404 Page Not Found” instead. Worse, you might not even notice it happening — Google keeps sending people to URLs that no longer work, and every one of those visits bounces.

If you want to know how to fix WordPress 404 error pages properly, you are in the right place. This guide walks you through exactly seven fixes, in the order you should try them — most cases are solved by the first two.

What Causes a WordPress 404 Error?

A 404 means the server found nothing at the requested address. WordPress itself is usually fine — the fault is in the layer that turns a URL into a post:

  • Broken permalink settings. WordPress stores rewrite rules that map URLs to posts. If those rules get out of sync — after a migration, a settings change, or a plugin update — every post can 404 at once.
  • A deleted or renamed page. The post is gone, but links to it still exist in menus, other posts, and Google’s index.
  • A corrupt or missing .htaccess file. On Apache servers, this small file carries the rewrite rules. If it is empty or damaged, WordPress cannot route requests.
  • A plugin conflict. A caching, security, or redirect plugin can hijack requests and send visitors to nowhere.
  • Server configuration. On Nginx there is no .htaccess, so a missing try_files rule produces the same symptom for a different reason.

The pattern tells you a lot: one dead page probably moved or was deleted; every post 404ing while the homepage loads means broken permalink rules.

A Real Scenario: Every Post 404s After Moving to a New Host

A friend runs a small bakery website — about forty pages and posts on WordPress. In November she moved to a faster host. The migration tool reported success and the homepage loaded perfectly. Then she clicked “Our Menu” and got a 404. Every post and page returned 404, except the homepage.

The homepage worked, so WordPress was running, the database was connected, and the content was still there — she could see the posts in the admin dashboard, full text intact. Only the public URLs failed. That points at one thing: the rewrite rules that turn a URL into a post were not working on the new server. A permalink problem, not a content problem.

She applied Fix 1 below — Settings, then Permalinks, then Save Changes, without changing anything — and every post came back instantly, all forty, in under a minute. Check what still works before you start changing things.

How to Fix WordPress 404 Error Pages: The 7 Fixes in Order

Fix 1: Flush Your Permalinks

In your WordPress dashboard, go to Settings → Permalinks. You will see your permalink structure — most sites use “Post name”. Do not change anything. Just scroll to the bottom and click Save Changes.

That click tells WordPress to regenerate its rewrite rules. On Apache it also rewrites the .htaccess file. As the official WordPress documentation on the Permalinks screen notes, simply visiting the Permalinks screen triggers a flush — but clicking Save Changes makes it certain.

After saving, open one of the broken posts in a new tab. If it loads, you are done. If it still returns 404, move on to Fix 2.

WordPress Settings Permalinks admin screen with permalink structure options and Save Changes button

Fix 2: Reset or Repair the .htaccess File

If flushing permalinks did not help, the .htaccess file itself may be damaged, empty, or missing. It lives in your WordPress root folder, next to wp-config.php, and it is hidden, so turn on “show hidden files” in your file manager.

First, download a copy of the current .htaccess as a backup. Then open it and look for the WordPress block:

# 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 your file is empty, garbled, or missing that block, replace its contents with the block above. If the file does not exist, create a new .htaccess in the root folder and paste the block in. Save, then click Save Changes on the Permalinks screen once more.

Code editor showing a WordPress .htaccess file with Apache rewrite rules

Fix 3: Flush Permalinks With WP-CLI

If you cannot reach the dashboard at all, WP-CLI does the same job as Fix 1 in one command. Connect over SSH, change into your WordPress root directory, and run:

wp rewrite flush

You should see: Success: Rewrite rules flushed. Test a broken URL right away. If you get Error: This does not seem to be a WordPress installation, you are in the wrong directory — check with pwd and ls until you can see wp-config.php, then run the command again.

Fix 4: Check for a Plugin Conflict

Sometimes the rewrite rules are fine, and a plugin breaks the request before WordPress routes it. Caching, security, and redirect plugins are the usual suspects, because they all touch URLs.

Go to Plugins → Installed Plugins and deactivate all of them at once using the bulk actions dropdown. Then test a broken page. If it loads, a plugin is the culprit. Reactivate your plugins one at a time, testing the page after each one, until the 404 comes back. The last plugin you activated is the one causing it.

With twenty plugins that takes about ten minutes and gives you a definite answer. Once identified, check the plugin’s settings first — an aggressive caching plugin can often be fixed with one toggle. If not, find an alternative and leave the broken one deactivated.

For the full step-by-step version, including what to do when a plugin locks you out of the dashboard, see our guide on how to find and fix a WordPress plugin conflict. The same method helps elsewhere — our guide to the WordPress white screen of death uses the same deactivate-and-test approach.

Fix 5: Fix the Nginx Configuration

Fixes 1 to 3 assume Apache, because Apache reads the .htaccess file. On Nginx there is no .htaccess, so flushing permalinks will not help — the routing rules live in the Nginx server block instead.

Open your site’s Nginx configuration file, usually in /etc/nginx/sites-available/ or /etc/nginx/conf.d/, and find the location / block. It should contain:

location / {
    try_files $uri $uri/ /index.php?$args;
}

That line tells Nginx: serve the file if it exists, serve the directory if it exists, otherwise hand the request to WordPress through index.php. Without it, Nginx looks for a physical file matching the URL, finds nothing, and returns 404 for every post.

After editing, run nginx -t, then reload with sudo systemctl reload nginx and test a broken post. If your host manages Nginx, open a support ticket and ask them to check the try_files rule — mention that posts 404 while the homepage works.

Fix 6: Set Up 301 Redirects for Moved or Deleted Pages

Some 404s are not errors at all — the page really is gone. You renamed a post, deleted an old page, or restructured your site. Visitors and Google still arrive at the old address, and no permalink flush will bring back a page that no longer exists.

The correct response is a 301 redirect: a permanent instruction sending visitors from the old URL to the most relevant live page. A 301 also passes most of the old page’s search ranking to the new one.

The easiest way is the free Redirection plugin. Install it, go to Tools → Redirection, and add one rule per dead URL: the old address as Source URL, the new address as Target URL. Test each redirect in a fresh tab.

Be honest about the target: redirect to the most closely related live post, not your homepage — Google treats homepage redirects as soft 404s. If no live page is a good match, let the URL 404 and handle it with Fix 7. Every few months, export your 404 list from Search Console and redirect the dead URLs that still get traffic.

Fix 7: Create a Helpful Custom 404 Page and Verify With Search Console

Even a perfect site produces some 404s — mistyped URLs, old links, bookmarks to deleted pages. This last fix makes those dead ends useful instead of frustrating.

Build a custom 404 page that says plainly the page could not be found, offers a search box, and links to your most popular pages. Most themes let you edit the 404 template under Appearance → Customize, or use the 404page plugin to assign any page as your error page. A branded, helpful 404 page keeps visitors on your site; a bare server error sends them back to Google.

Then verify in Google Search Console. Open the Pages report and check the “Not found (404)” section — the URLs there should be pages you expect to be gone. Any live page showing up is a problem: fix it with the earlier steps. Submit fixed URLs for re-indexing with the URL Inspection tool and check back in a week.

Our roundup of common WordPress errors and their fixes puts the 404 in context alongside the white screen and the memory exhausted error.

How to Prevent WordPress 404 Errors

Before any migration, export your permalink settings and a copy of .htaccess. Restore them on the new host before switching DNS, and test five or six posts right after the move.

  • Never delete a page that gets traffic without a redirect. Check Google Search Console first; if a page still receives visits, set up the 301 before you delete it.

Check your 404 log monthly. Search Console’s Pages report shows which dead URLs visitors hit. Fix the ones with traffic; ignore random bot probes.

  • Update one thing at a time. When a plugin update or a settings change triggers 404s, you will know exactly what caused it if you changed only one thing.
  • Keep your permalink structure stable. Switching from “Day and name” to “Post name” changes every URL on your site. If you must change it, plan the redirects first.

Conclusion

Learning how to fix WordPress 404 error pages is mostly about working in the right order. Flush permalinks first — that alone fixes most cases in under a minute. Repair .htaccess if the flush did not take. Use WP-CLI when the dashboard is out of reach. Hunt plugin conflicts methodically. Fix the Nginx try_files rule if you are on Nginx. Redirect pages that genuinely moved, and finish with a custom 404 page.

The bakery site never had a content problem — it had a routing problem, and one click fixed it. Start with Fix 1, test after every step, and stop as soon as your pages load.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe Today

GET EXCLUSIVE FULL ACCESS TO PREMIUM CONTENT

LATEST UPDATES REGULARLY

GET EXCLUSIVE CONTENTS ON WORDPRESS, THEMES, PLUGINS & TOOLS

REGULAR PROMOTIONS AND TIPS

Get unlimited access to our EXCLUSIVE Content and our archive of subscriber stories.

Exclusive content

Latest article

More article