404 Not Found: What It Means and How to Fix It

Last tested: October 22, 2026 · By Alex

A 404 Not Found error means the server is reachable and understood the request, but it has nothing at that URL. The page may have been deleted or moved, the link may be wrong, or the server may not know how to route the URL to the content that does exist.

This guide covers 404 errors in general: for visitors, for site owners on Apache and NGINX, and behind Cloudflare. If your WordPress homepage works but every post or page returns 404, go straight to the dedicated guide: WordPress 404 Error on Posts.

Quick Fix

  • Check the URL for typos, wrong capitalization, missing or extra trailing slashes.
  • Reload the page and try a private window to rule out a cached 404.
  • Go up one level in the URL path or use the site search.
  • Check whether the page was moved: search site:example.com keyword in Google.
  • Site owners: check whether the page or file actually exists and is published.
  • WordPress: go to Settings → Permalinks and click Save Changes.
  • Check rewrite rules in .htaccess (Apache) or try_files (NGINX).
  • Add 301 redirects for moved or deleted pages that still get traffic.

What Is 404 Not Found?

404 Not Found is an HTTP client error status code. The server is telling the client that it cannot find a resource at the requested URL. It does not say whether the absence is temporary or permanent.

Related codes worth knowing:

  • 410 Gone: the resource was removed on purpose and will not return. Search engines tend to drop these URLs faster.
  • 403 Forbidden: the resource exists, but access is denied. Some servers return 404 instead of 403 to hide that a resource exists.
  • Soft 404: a page that says “not found” but returns status 200. Google Search Console reports these separately, and they should be fixed so the status code matches the content.

Why 404 Not Found Happens

1. Wrong or Outdated Links

Typos in internal links, external sites linking to old URLs, or bookmarks saved years ago. The most common source of 404s on any site.

2. Content Deleted or Moved Without a Redirect

Changing a slug, merging two posts, or moving to a new URL structure without 301 redirects leaves the old URL returning 404.

3. Broken Rewrite Rules

CMSs like WordPress route “pretty” URLs through index.php. If .htaccess is missing, mod_rewrite is off, or NGINX lacks the right try_files directive, real content returns 404.

4. Case Sensitivity

Linux file systems are case-sensitive. /Images/Logo.png and /images/logo.png are different files. Sites moved from Windows hosting often break this way.

5. Wrong Document Root

After a migration or a new virtual host, the server may point at the wrong folder. Every URL then returns 404 except files that happen to exist in that folder.

6. Missing Static Assets

CSS, JavaScript, fonts, and images can return 404 after a cache plugin, theme update, or CDN change. The page loads, but looks broken.

7. Unpublished or Private Content

Drafts, scheduled posts, and private pages return 404 to visitors who are not logged in.

How to Fix 404 Not Found Step by Step

1. Verify the URL and Status Code

curl -I https://example.com/some-page/

Confirm it is a real 404 and not a redirect to a 404. Also test the variant with and without the trailing slash, and with www and without it.

2. Check That the Content Exists

In WordPress, search for the post in Posts → All Posts, including Drafts and Trash. For static files, check over SSH:

ls -la /var/www/example.com/public/images/

3. Flush WordPress Permalinks

Open Settings → Permalinks and click Save Changes without changing anything. WordPress regenerates its rewrite rules and, on Apache, tries to rewrite .htaccess. With WP-CLI:

wp rewrite flush --hard

If this fixes it, something (a plugin, a migration, a manual edit) had broken the rules.

4. Restore the Default .htaccess (Apache)

The standard WordPress block:

# 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

If WordPress is in a subfolder, change RewriteBase / to RewriteBase /subfolder/ and the last rule to /subfolder/index.php. Make sure mod_rewrite is enabled and the virtual host allows overrides:

sudo a2enmod rewrite

<Directory /var/www/example.com/public>
    AllowOverride All
</Directory>

sudo apachectl configtest && sudo systemctl reload apache2

5. Fix try_files in NGINX

NGINX ignores .htaccess. For WordPress and most PHP front-controller apps, the location / block needs:

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

Without the /index.php?$args fallback, every pretty URL returns 404. Test and reload with sudo nginx -t && sudo systemctl reload nginx.

6. Check the Document Root

# NGINX
grep -R "root " /etc/nginx/sites-enabled/

# Apache
grep -R "DocumentRoot" /etc/apache2/sites-enabled/

Make sure it points to the folder where index.php or your site files actually live.

7. Add 301 Redirects for Moved Content

When a URL has changed, redirect the old one to the most relevant new page, not to the homepage. In WordPress, the free Redirection plugin handles this and logs 404s. On Apache:

Redirect 301 /old-page/ https://example.com/new-page/

On NGINX:

location = /old-page/ {
    return 301 https://example.com/new-page/;
}

For content that is gone with no replacement, a 410 is more honest than a redirect to an unrelated page.

Advanced Troubleshooting

Find 404s in Access Logs

awk '$9 == 404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20

This lists the most requested missing URLs. Fix the ones with real traffic first. Requests for /wp-login.php on non-WordPress sites or random .env files are bot scans, you can ignore them.

Use Google Search Console

Under Indexing → Pages, check “Not found (404)” and “Soft 404”. The report shows which URLs Google tried and, often, where it found the link.

Crawl Your Own Site

A crawler such as Screaming Frog or the free wget spider finds broken internal links:

wget --spider -r -nd -nv -l 3 -o crawl.log https://example.com/
grep -B1 "404" crawl.log

Check Case Sensitivity Issues

find /var/www/example.com/public -iname "logo.png"

If the file exists with different capitalization, fix the link or rename the file.

Make Sure Your Custom 404 Page Returns 404

A custom error page is good for visitors, but it must still send the 404 status. Check it with curl -I https://example.com/this-does-not-exist/. If you see 200 OK, search engines treat it as a soft 404. On Apache, set it with ErrorDocument 404 /404.html. On NGINX, use error_page 404 /404.html; and never point it to a redirect.

WordPress-Specific Causes

  • All posts 404, homepage works: rewrite rules or .htaccess. See WordPress 404 Error on Posts for the full walk-through.
  • Custom post types 404: the plugin or theme registering them changed, or rules were not flushed after activation. Save permalinks again.
  • Slug conflicts: a page and a category, or a post and an attachment, with the same slug can send one of them to 404.
  • Media files 404: check wp-content/uploads permissions and whether an offload or CDN plugin rewrites image URLs.
  • After a migration: update URLs in the database with wp search-replace 'https://old.com' 'https://new.com' --dry-run, then run it without --dry-run.

The Cloudflare Angle

Cloudflare passes 404 responses from your origin as they are, but it can also cause or hide them:

  • Cached 404s: with “Cache Everything” rules, a 404 can stay in cache after you publish the page. Purge the specific URL in Caching → Configuration → Custom Purge.
  • Redirect Rules and Page Rules: a broad rule can send traffic to URLs that do not exist. Check rules that match the failing path.
  • Workers or Pages routes: if a Worker or Pages project is bound to the route, it answers instead of your origin.

Test the origin directly with curl -I --resolve example.com:443:ORIGIN_IP https://example.com/some-page/. If the origin returns 200 and Cloudflare returns 404, the issue is on the Cloudflare side.

Prevention Tips

  • Always add a 301 redirect when you change a slug or delete a page that has traffic or backlinks.
  • Keep URLs short and lowercase, without dates you will want to change later.
  • Check Search Console’s 404 report once a month.
  • Run a broken link crawl after big content changes or migrations.
  • Use a helpful custom 404 page with search and links to main sections, and make sure it still returns status 404.
  • Back up .htaccess and NGINX configs before editing them.

When to Contact Support

Contact your host if every URL returns 404 including the homepage, if you cannot change the document root, or if mod_rewrite or AllowOverride are disabled on shared hosting. Include a few failing URLs, the time the problem started, and any recent changes such as a migration or PHP version update.

Frequently Asked Questions

What does 404 Not Found mean?

The server is reachable and understood the request, but there is no resource at that URL. The page may have been deleted, moved without a redirect, or the server cannot route the URL to existing content.

Do 404 errors hurt SEO?

404s for pages that never existed are normal and do not hurt the site. The problem is 404s on pages that had traffic or backlinks, because that value is lost. Redirect those with a 301 to the most relevant page.

Should I return 404 or 410 for deleted pages?

Use 410 Gone when the content is removed on purpose and has no replacement. Use a 301 redirect when a close replacement exists. Use 404 when you are not sure.

Why does my WordPress site show 404 on every post but the homepage works?

The rewrite rules are broken. Go to Settings, Permalinks and click Save Changes, then check .htaccess on Apache or try_files $uri $uri/ /index.php?$args on NGINX.

Final Thoughts

Most 404 errors fall into two groups: content that really is missing, and content that exists but the server cannot route to it. For the first, fix links and add 301 redirects. For the second, check permalinks, .htaccess, try_files, and the document root. Watch your logs and Search Console so new 404s get caught before they cost you traffic.

Related HTTP Errors

Leave a Comment