Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

How to Fix the WordPress 404 Error: 7 Causes and Fixes (2026)

A WordPress 404 error on a post you know exists is one of the most confusing errors in WordPress. The content is right there in your dashboard, the link worked yesterday, and yet visitors get a “Page not found” screen. The good news: in most cases the content is fine and the fix takes under a minute. The bad news: the fix depends entirely on which 404 you have, and guessing the wrong one wastes an afternoon.

This guide shows you how to diagnose a WordPress 404 error in about sixty seconds, then work through the seven real causes in order. Every fix below is verified against the official WordPress documentation, current as of November 2026.

First, the 60-second diagnosis

Before you change anything, answer three questions. They tell you which layer is broken, and which fix to jump to.

1. Does the home page load?

If the home page loads but posts and pages 404, the problem is almost always URL rewriting: WordPress cannot turn pretty URLs into database queries. Jump to Fix 1. If everything 404s, including the home page, the problem is more likely the Site URL or the server itself — check Fix 5 first, then Fix 2.

2. Whose 404 is it — WordPress or the server?

A WordPress 404 wears your theme: your header, your footer, your “Page not found” template. A server 404 is a plain, unstyled page that says something like “404 Not Found — Apache” or “404 Not Found — nginx”. A themed 404 means the request reached WordPress but WordPress could not match the URL to any content. A plain server 404 means the web server gave up before WordPress ever ran.

3. Does the plain URL work?

Find the post’s ID (hover over it in Posts → All Posts and read post=123 in the link), then visit https://yoursite.com/?p=123. That address needs no rewriting at all. If the post loads, your content is fine and the rewriting layer is the problem. If even ?p=123 fails, the problem is the content itself — check Fix 7.

Run those three tests now, then start at the fix that matches your result — and test after each one, so you know which fix actually worked.

Fix 1: Resave your permalinks

This is the fix that resolves most WordPress 404 errors, and it takes ten seconds. WordPress stores its URL rewrite rules in the database. A migration, a core update, a plugin that registers a new post type, or a manual edit to .htaccess can leave those stored rules out of date. Any address the stale rules cannot match returns a 404, even though the post exists.

  1. Go to Settings → Permalinks in your dashboard.
  2. Leave the structure exactly as it is. Changing it would change every URL on your site.
  3. Click Save Changes.

Saving rebuilds the rewrite rules and, on Apache or LiteSpeed, rewrites .htaccess with fresh rules. Open the broken post again. If it loads, you are done — this was the whole problem.

If you prefer the command line, or you cannot reach the dashboard, WP-CLI does the same thing:

wp rewrite flush --hard

The --hard flag updates the .htaccess rules as well as the rewrite rules in the database. The plain wp rewrite flush without the flag only updates the database rules, so use --hard when the problem is on Apache. Note that a hard flush works only on single-site installs.

Fix 2: Restore the default .htaccess file

If resaving permalinks did not help, the .htaccess file itself may be missing, empty, or corrupted — a common result of a bad migration or a plugin that rewrote it. The file lives in your WordPress root directory (the folder containing wp-config.php), not inside wp-admin or wp-content. Note that file managers and FTP clients hide files starting with a dot by default, so turn on “Show hidden files” before concluding it is missing.

Download a backup of the file first, then replace its contents with the standard WordPress block from the official WordPress documentation:

# 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

That block is the entire hand-off: every request that is not a real file or directory gets passed to index.php, and WordPress takes it from there. If your site is installed in a subdirectory, for example example.com/shop/, use the subfolder in two places: RewriteBase /shop/ and RewriteRule . /shop/index.php [L].

File permissions matter here. The file should normally be 644 — readable by WordPress, not writable by the world. If WordPress cannot write to it, the Permalinks screen will say so at the bottom and show you the rules to paste in by hand. Some guides suggest temporarily setting 666 to let WordPress write the file; if you do that, change it back to 644 immediately afterwards, because 666 lets anyone write to the file.

Fix 3: Apache is ignoring .htaccess

Sometimes .htaccess is perfect and the server simply never reads it. This is the most frequent cause on a new server or a fresh VPS, and it produces a plain server 404 while the WordPress dashboard works fine.

Two things must be true for Apache to honour .htaccess:

mod_rewrite is enabled

On Debian and Ubuntu, enable it and reload Apache:

sudo a2enmod rewrite
sudo apachectl configtest && sudo systemctl reload apache2

AllowOverride is set for your site directory

Apache only reads .htaccess files in directories where overrides are allowed. In your virtual host or Apache configuration, the directory block for your site must say:

<Directory /var/www/html>
    AllowOverride All
</Directory>

With AllowOverride None, .htaccess is silently ignored — WordPress writes its rules into a file nothing ever reads. After changing this, test the configuration and reload Apache with the command above. If you see a 403 error rather than a 404 after touching these settings, the directory permissions or ownership changed, not the rewrite rules — check that the web server user can read the site directory before chasing the rewrite config further.

Fix 4: Add the nginx try_files rule

If your site runs on nginx, there is no .htaccess file at all — nginx does not read one, and WordPress cannot generate rewrite rules for you. The server block needs a try_files line that hands unknown addresses to index.php. This is the single most common cause of WordPress 404 errors on nginx, and it is also the fix most Apache-focused guides never mention.

In your server block, the location block for the site root should look like this, as shown in the official WordPress nginx documentation:

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

That line says: serve the file if it exists, serve the directory if it exists, otherwise pass the request to index.php with the query string intact. The ?$args part matters — without it, non-default permalinks break when a query string is present.

After editing, test and reload:

sudo nginx -t && sudo systemctl reload nginx

If you are on managed hosting, you cannot edit the nginx configuration yourself — send your host the try_files line above and ask them to check it. On a multisite install the same line applies, but check the official WordPress nginx guide for the multisite server blocks, which add extra rewrite rules for the subsite paths.

Fix 5: Wrong Site URL after a migration

If the 404s started right after moving your site to a new domain or a new host, check the two URL settings WordPress stores in the database. WordPress uses them to build every URL on the site, so a stale value causes widespread 404s — often including the admin area itself.

  1. Go to Settings → General and check WordPress Address (URL) and Site Address (URL).
  2. If either still shows the old domain, update both to the new domain, including https:// if you have SSL active.
  3. Click Save Changes.

If you cannot reach the dashboard at all, WP-CLI can check and fix the values directly:

wp option get home
wp option get siteurl
wp option update home 'https://new-domain.example'
wp option update siteurl 'https://new-domain.example'

There is one trap: if wp-config.php defines WP_HOME and WP_SITEURL constants, those take priority over the database values. If the database values look right but the site still redirects to the old domain, open wp-config.php and check for those two lines — update them, or delete them so WordPress uses the database values again.

A migration also leaves old URLs inside post content, widgets, and theme settings, which cause broken images and internal links even after the main 404 is fixed. Run a proper search-and-replace on the database (WP-CLI’s wp search-replace handles serialised data correctly; a raw SQL REPLACE() does not) and then resave permalinks once more.

Fix 6: A plugin or theme conflict

A plugin that rewrites URLs — a security plugin, a caching plugin, a custom post type plugin, a multilingual plugin — can break rewriting for the whole site, usually right after an update. If the 404s started after you installed or updated something, isolate it.

  1. Deactivate all plugins at once (Plugins → Installed Plugins, select all, choose Deactivate from the bulk menu).
  2. Resave permalinks (Fix 1), then test the broken page.
  3. If it loads, reactivate plugins one at a time, testing after each, until the 404 returns. That plugin is the culprit.
  4. If it still 404s with every plugin off, switch to a default theme such as Twenty Twenty-Five and test again.

If you cannot reach the dashboard, rename the wp-content/plugins folder over FTP or SSH — WordPress deactivates every plugin at once when it cannot find the folder. Rename it back afterwards and reactivate one by one. The same trick works for themes: rename the active theme’s folder and WordPress falls back to a default theme.

When you find the offending plugin, check whether it has an update that fixes the issue before replacing it. Some plugins — particularly ones that register custom post types — need a permalink resave after every activation, because registering a post type adds new rewrite rules that do not take effect until the rules are rebuilt. If a plugin’s own pages 404 right after activation, resaving permalinks is usually the entire fix.

Fix 7: The content itself is gone (or never was published)

Sometimes the 404 is correct, and the fastest fix is to accept that. Check the post itself before rebuilding your server:

  • In the Trash? A trashed page returns a 404 to visitors. WordPress keeps trashed items for 30 days by default before deleting them permanently. Go to Pages → All Pages, click Trash, hover over the page and click Restore.
  • Draft, scheduled, or private? A draft or scheduled post 404s for everyone except logged-in users who can preview it. A private post 404s for everyone except logged-in users with permission to read it. If the post should be public, change its status to Published.
  • Slug changed? The slug is the last part of the URL — about-us in example.com/about-us/. If someone edited it, the old address 404s. Open the post, click Quick Edit, and check the Slug field against the URL people are actually visiting.
  • Wrong post type? Custom post types (products, events, portfolio items) have their own URL rules. If a plugin was deactivated, its post type’s pages 404 because WordPress no longer knows what that type is. Reactivate the plugin, then resave permalinks.

Also check for slug conflicts: two pieces of content cannot share a URL. If a page and a post, or a post and a category, end up with the same slug, WordPress serves one and 404s the other. The fix is to rename one of them.

After the fix: redirects, monitoring, and prevention

Fixing the 404 is only half the job. The other half is making sure nobody — visitor or search engine — hits a dead end again.

Redirect moved content with a 301

If a page moved or its slug changed, set up a 301 redirect from the old address to the new one. A 301 tells browsers and search engines the move is permanent, so old links and rankings follow the page instead of dying. The free Redirection plugin (available from the WordPress plugin directory) does this from the dashboard: Tools → Redirection, add the old URL as the source and the new URL as the target. Do not redirect everything to the home page — that is barely better than a 404 for visitors, and search engines treat it as a soft 404 anyway.

Find the 404s you do not know about

Visitors rarely report 404s; they just leave. Google Search Console lists every URL Google tried to crawl that returned a 404, under Pages → Not found (404). Check it monthly. A 404 log plugin (Redirection includes one) shows the same for real visitors, including the referrer, so you can see whether the broken link lives on your own site or someone else’s.

Stop it happening after the next migration

Most WordPress 404 errors are self-inflicted during a move or an update. Three habits prevent nearly all of them:

  • Back up before you touch anything. A database backup before a migration or a permalink change means a bad edit is a five-minute restore, not a rebuild.
  • Resave permalinks after every migration, plugin activation, and post-type change. It costs ten seconds and rebuilds the rules that break most often.
  • Test on staging first. A staging copy lets you run the migration, the update, or the plugin change and check every key page before the live site ever sees it. If you do not have one yet, setting up a staging site is a one-off job that pays for itself the first time it catches a broken migration.

When to call your host

If you have worked through all seven fixes and the 404s persist, the problem is below the level WordPress can reach: a server configuration you cannot edit, a corrupted Apache or nginx configuration, or a host-level caching layer serving stale 404 responses. Before you call, gather three things: whether the 404 is themed or plain, whether ?p=123 loads, and what changed just before the errors started. That is exactly what support will ask, and having the answers ready turns a two-day ticket into a ten-minute fix. If your host runs nginx and you cannot edit the server block, the try_files line in Fix 4 is the exact snippet to send them.

A WordPress 404 error looks like a content problem, but it is almost always a routing problem. Diagnose first, fix in order, test after each step — and the post that “disappeared” will be back before your coffee cools.

Last verified: 22 November 2026, against the official WordPress documentation (wordpress.org and developer.wordpress.org).

Further Reading & References

Related on HowToShipIt: How to Fix the WordPress White Screen of Death, How to Fix the WordPress Critical Error, How to Move WordPress to a New Host Without Downtime, How to Fix “Error Establishing a Database Connection” in WordPress, How to Create a WordPress Staging Site.

Leave a Comment