404 Not Found Error: How to Fix

By
Vladimir Kaplarevic
Published:
June 19, 2025

When a server receives a request from a client application, like a browser or API, it returns an HTTP status code to signal the outcome. A 200 OK response confirms the request was successful.

Codes in the 4xx range, however, indicate that there is a problem with the client's request, and the server is unable to process it. 404 Not Found is one of the most common examples of a client-side error.

Find out what the 404 error means, its causes, and how to fix it, whether you are visiting a website or managing one.

Steps to fix the 404 Not Found error.

What Is a 404 Error?

404 Not Found is an HTTP status code that indicates the server was unable to find the requested page, file, or API endpoint at the specified URL path.

This error usually means that the resource has been deleted or moved without a redirect, or that the client attempted to access an incorrect or outdated URL.  

Different Forms of 404 Error

The appearance of the 404 error depends on how the server is configured and how the browser renders the server's response. Below are some of the most common examples.

Generic Browser Message

When a server returns a 404 status, most browsers, like Chrome, Firefox, and Edge, generate and display a stylized default message with the following or similar wording:

404. That's an error. The requested URL was not found on this server. That's all we know.

404 error in Chrome.

This type of message is shown if the server has not been configured to display a customized 404 error page.

Custom 404 Pages

Modern websites often use the 404 response to display a custom error page. These pages are designed to retain visitors who land on outdated or broken links. They usually contain:

  • A friendly message that explains what went wrong.
  • Links back to active pages, such as the homepage.
  • A search bar to help users find what they are looking for.
  • Site branding and links to trending or popular content.
Custom 404 error page.

Raw Server Message

If no styling is applied and a custom error page is not configured, the browser may display a plain HTML message. This message is generated directly by the web server and contains only minimal information. For example:

Not Found. The requested URL /404 was not found on this server.

Raw HTML 404 error page.

The lack of information on this page can negatively impact the user experience.

API Error Responses

When an API cannot locate a requested resource, it usually returns a 404 Not Found status code and a structured response. Here is an example of a structured JSON response:

{
  "status": 404,
  "error": "Not Found",
 "message": "The requested resource was not found."
}

Some APIs also include contextual information, such as endpoint paths, IDs, or internal error codes, to help web developers troubleshoot the issue.

Note: Learn more about related HTTP codes, such as 401 Unauthorized and 403 Forbidden, and how they differ from 404 Not Found.

Hard 404 Vs. Soft 404

There are two types of 404 errors: hard 404s and soft 404s. End users are largely unaffected, but soft 404 errors have significant implications for SEO and API behavior.

A hard 404 error occurs when a server cannot locate the resource at the specified URL and correctly responds with a 404 Not Found status.

A soft 404 error happens when the resource is missing, but the server is configured to respond with a 200 OK message instead. The user sees an error message or blank page, but the underlying status code indicates that the content was served. The table below shows the summary:

Error TypeServer ResponseClient ExperienceSEO and API Impact
Hard 404404 Not FoundThe resource is missing, and the server confirms its absence.Correctly handled by APIs and search engines. Signals that the content is no longer available and should be removed from indexing.
Soft 404200 OKThe user sees an error message, but the server responds with a 200 success status code.Misleads APIs and search engine crawlers. It harms SEO and leads to ranking penalties.

Some websites return soft 404s intentionally to preserve the SEO value of their deleted pages. Search engines like Google highly discourage this approach, which may flag, de-rank, or even exclude these pages from search results.

What Causes 404 Errors?

The most common causes of the 404 error are listed in the sections below.

Client-Side Issues

Common client-side issues include:

  • Incorrect URL. The URL points to a non-existent page, often due to a typo or copy-paste error.
  • Cached URLs. An old URL that has since been removed from the website is still stored in the browser cache or bookmarks section. When the user tries to visit the page, the host server returns a 404 error.
  • Broken link. A link from an external source, such as an email or social media post, is incorrect and points to a non-existent or deleted resource.

Server-Side Issues

Server-side issues that can lead to a 404 error are:

  • Deleted content. The requested content is missing.
  • No redirect. The page was moved, but a proper redirect was not set up.
  • File permissions. The content is at the requested location, but the server cannot access the resource due to incorrect file or directory permissions.
  • Incorrect CMS routing. The Content Management System (CMS) or application routing rules are not configured correctly and are failing to handle the requests properly.
  • DNS propagation. If your website has recently changed hosting providers or updated DNS records, it can take up to 48 hours for the changes to propagate across global DNS servers. During this period, some users may be redirected to an outdated IP address and receive a 404 Not Found error.

API and Backend Issues

API and backend configuration issues can also cause error 404, for example:

  • Invalid resource ID. The request is targeting an object or ID that does not exist. For example, the GET /users/Mike request will return a 404 error if the user Mike has been deleted.
  • Incorrect endpoint. The request targets an endpoint with an incorrect URL path. A simple typo, such as targeting the /api/v1/payment-token endpoint instead of the valid /api/v2/payment-token version, will likely result in a failed request if v1 has been deprecated.
  • Unsupported HTTP method. The correct endpoint is called, but it uses an unsupported HTTP method. For instance, using the GET method to update a server resource does not work, as this method is only used for read-only operations.

How to Troubleshoot 404 Errors as a User?

If you encounter a 404 Not Found error while browsing, the page was likely moved or no longer exists. However, there are several steps you can take to check whether the error was triggered by a mistake on your end.

Check URL

Confirm that the URL is correct. Even small errors, such as duplicate forward slashes, typos, or missing file extensions, can prevent the server from locating the requested page. For example, entering the following URL results in a 404 error:

https://www.ccbill.com/aboutt

Removing the extra character allows the server to serve the correct page:

https://www.ccbill.com/about

Always check URLs in emails, social media posts, or chat messages, as these may have been copied or formatted incorrectly.

Search Website Manually

Websites frequently redesign their layout, restructure content, and move and rename pages. The page you are looking for may still exist, but has been moved to a different location. Use the website's navigation menu or a search tool, if one is available, to locate the relevant resource.

Search bar on the phoenixnap KB page.

Try a Different Device

Browsers and operating systems cache browsing data, such as URLs and IP addresses, to improve loading speeds and reduce the number of server requests. If a website has moved or deleted a page, your device may still be relying on outdated cached data, which can trigger a 404 Not Found Error.

If the link is correct, try accessing the page from a different device to determine whether the issue is caused by local caching.

Clear Cache

If the website is accessible from a different device, the local cache is the likely cause of the 404 error. To fix this issue, clear the browser's cache.

To clear the cache in Chrome:

1. While the browser is open, press Ctrl-Shift-Del.

2. Select the Basic tab.

3. Check the Cached images and files box.

4. Click Delete data and reload the website.

Clearing the cache in Chrome to fix the 404 error.

To clear the cache in Firefox:

1. Open the browser and press Ctrl-Shift-Del.

2. Set the time range using the When dropdown.

3. Check the Temporary cached files and pages option.

4. Click Clear.

Clearing the cache in Firefox to fix a 404 error.

Reload the website to confirm the 404 error is resolved.

To clear the cache in Safari, press Cmd+Alt+E and reload the page.

Contact Website Owner

If the URL continues to return a 404 Not Found status even after attempting the previous steps, contact the website owner to inform them that the page is inaccessible. Look for a Contact Us section on the site and include the full URL of the page that returned the error.

Website owners appreciate these reports, as fixing broken links improves SEO performance and leads to better user experiences.

How to Fix 404 Errors as a Website Administrator?

When a user reports a 404 Not Found error on your website, try visiting the same URL to confirm the issue. If you can reproduce the error, follow the steps in the sections below to identify and resolve the cause.

Step 1: Check Server Logs

Server access logs capture incoming HTTP requests and the server's responses. The log entries reveal response status codes, URLs, request methods, and the timestamps of the events.

The location of the access logs depends on the system's operating system and web server. For example, on a Linux system running Apache or NGINX, the default paths are:

Apache

/var/log/apache2/access.log

NGINX

/var/log/nginx/access.log

Note: The commands in this guide are presented using Ubuntu 24.04.

To review access logs on an Apache server:

1. Connect to the server via SSH and open a terminal session.

2. Use the tail command to view the last 100 access log entries:

sudo tail -n 100 /var/log/apache2/access.log

3. Utilize the grep command to search for entries that reference the 404 error:

sudo grep " 404 " /var/log/apache2/access.log

4. If testing in real-time, enter the following command to review logs as requests come in:

sudo tail -f /var/log/apache2/access.log

Examples of Apache log entries contain the following information:

192.168.1.10 - - [11/Jun/2025:13:47:23 +0000] "GET /about-us HTTP/1.1" 404 487 "-" "Mozilla/5.0"
203.0.113.22 - - [11/Jun/2025:14:01:12 +0000] "GET /api/data.json HTTP/1.1" 404 234 "-" "curl/8.0"

5. Review the entry and check if:

  • The status code confirms that a 404 error occurred.
  • The URL does not contain typos, missing characters, or incorrect syntax.
  • The correct request method was used (i.e., GET, POST).
  • The timestamp correlates with error entries in other logs and systems.

The access log helped you determine if a client-side issue, a missing resource, or a misconfigured path caused the 404 error.

Step 2: Verify File Exists and Its Path

If the requested resource is not at the expected location, check if it exists on the server and that the correct path is configured. The steps to verify the file's location depend on whether the website uses a CMS or serves static files.

Fix CMS Routing Issues

A CMS like WordPress does not serve files directly from the server's file system. Instead, requests are routed through application logic and mapped to content in a database. A 404 error may occur due to deleted or unpublished pages, broken permalinks, or conflicts with plugins and themes.

To check for routing issues in WordPress:

1. Access the WordPress Dashboard.

2. Click Posts (or Pages) and review the list of posts. It is possible that the resource was accidentally unpublished or moved to the Trash folder.

Post status in WordPress Admin with 404 error.

3. Open the affected post or page and click the Slug field. Confirm the URL slug matches the URL returning the 404 error.

Updating slug in WordPress.

If there is a mismatch, adjust the slug to match the correct path. This is one of the most common reasons for the 404 error in CMS-driven websites.

4. Return to the Dashboard, then navigate to Settings and select Permalinks.

5. Click Save Changes without modifying any settings. This flushes the WordPress permalink structure and regenerates the .htaccess file rewrite rules.

Reset permalinks in WordPress.

6. Conflicting or corrupted plugins may override or interfere with default routing behavior. Go to Plugins and temporarily deactivate all plugins.

Deactivating plugins in WordPress.

Try to load the URL, which returns a 404 error. If the page loads successfully, enable one plugin at a time and test the URL after each activation to isolate the faulty plugin. Contact the plugin developer's support service to report the issue.

7. Custom or headless themes may affect default CMS routing. Go to Appearance and open the Themes menu. Temporarily switch to a default theme like Twenty Twenty.

Select default theme in WordPress.

Reload the page to confirm that the URL is now accessible.

Note: To ensure the server is not serving outdated data, clear the CMS cache using a caching plugin (i.e., W3 Total Cache or LiteSpeed Cache). Also, purge the Content Delivery Network (CDN) cache if your site uses one, such as Cloudflare.

Static Web Pages

In a static website, files are served directly from the server's file system. For example, the default document root for Apache is:

/var/www/html

If the access log shows that a specific file returns a 404 error, like in this example:

"GET /kb/uploads/linux-commands-cheat-sheet.pdf HTTP/1.1" 404

The corresponding file should exist at:

/var/www/html/kb/uploads/linux-commands-cheat-sheet.pdf

To confirm that the file is at the expected location:

1. Use the ls command to confirm the file's path:

sudo ls -l /var/www/html/kb/uploads/linux-commands-cheat-sheet.pdf

2. Linux is case-sensitive, and requesting Linux-commands-cheat-sheet instead of linux-commands-cheat-sheet will result in a 404 error. Use a wildcard to help search for variations:

sudo ls /var/www/html/kb/uploads/*cheat*

3. Confirm the file has the correct permissions with the chmod command:

sudo chmod 644 /var/www/html/kb/uploads/linux-commands-cheat-sheet.pdf

4. Ensure that the parent directory is executable:

sudo chmod 755 /var/www/kb/uploads/linux-commands-cheat-sheet.pdf

Note: If the Apache .htaccess file or another configuration file is present in the same directory, review the file for directives that could block access.

Step 3: Set Up Redirects

If a page was removed or moved to a different location, you need to establish redirects to the new or replacement content to preserve its SEO value.

There are three types of redirects:

CodePurposeUse Case
301Permanent redirect.The page has been permanently moved, and replacement content is available at a different URL.
302Temporary redirect.The page is temporarily unavailable but will return soon.
307A temporary redirect that preserves the API request method.The page has been temporarily moved. Unlike the 302 code, 307 guarantees that the original HTTP method and the request body are preserved during the redirection.

Set Up Redirects in WordPress

One of the easiest and most common ways to manage redirects in WordPress is by using the free Redirection plugin.

To install the plugin and configure redirects in WordPress:

1. Log in to the WordPress Dashboard.

2. Go to Plugins and click Add New Plugin.

Installing the Redirection plugin in WordPress.

3. Type Redirection in the search bar and click Install Now to install the plugin.

Searching for and installing the Redirection plugin in WordPress.

4. Click Activate once the installation is complete.

5. Go to Tools and select Redirection.

Open the Redirection plugin in WordPress.

6. Click Add New and expand the Show advanced options section.

Advanced options for WordPress redirections.

7. Enter the following values:

  • Source URL: /page-giving-404
  • Target URL: /replacement-page
  • HTTP code: 301

8. Click Add Redirect.

Setting up a 404 redirect in WordPress.

9. Open a terminal or command prompt and use the curl command to test the redirect:

curl -I https://yourwebsite/page-giving-404

The expected output for a 301 redirect is:

HTTP/1.1 301 Moved Permanently
Location: https://yourwebsite.com/replacement-page

Note: Always point each redirected URL to its final destination. Redirecting a URL that is already redirected or creating loops by redirecting a page back to itself can negatively impact SEO and confuse both search engines and users.

Setting Up Redirects in .htaccess File (Apache)

If your website runs on an Apache web server, you can manually configure URL redirects using the .htaccess file in the website's root directory.

To set up redirects:

1. Open a terminal and use a text editor, such as Nano, to open the .htaccess file:

sudo nano /var/www/html/.htaccess

2. Add the following lines to configure a permanent redirection rule:

Redirect 301 /old-page.html /new-page.html

To establish a temporary redirect, for example, during maintenance windows, enter:

Redirect 302 /event /maintenance-notice

3. Press Ctrl+X, then y, and Enter to save the file and exit Nano.

4. Test the redirect to confirm it works using the curl command:

curl -I https://yourwebsite.com/page-giving-404

The expected output for a 301 redirect is:

HTTP/1.1 301 Moved Permanently
Location: https://yourwebsite.com/replacement-page

There is no need to restart the Apache service after editing the file. Apache reads the .htaccess file on each request, and changes take effect immediately.

Note: For more advanced redirect logic, consider using the mod_rewrite module in Apache.

Step 4: Fix Broken Internal Links

The 404 error the user reported may not be the only broken link on the website. To ensure that all internal links work, use automated link-checking tools to perform a full audit.

Popular tools for auditing links include:

ToolPlatformFeatures
Google Search ConsoleWeb-basedThe service is free. It requires owners to verify website ownership before usage.
Screaming Frog SEOWindows/macOSFree for up to 500 URLs. A full-blown local SEO crawler and audit tool.
Ahrefs Site AuditWeb-basedPaid tool with extensive crawl reports and link data.
SEMrushWeb-basedPaid tool offering site audits, link tracking, and issue prioritization.
SitebulbWindows/macOSPaid crawler with visual reports and in-depth technical analysis.

Besides broken links, these tools also report:

  • HTTP response codes, for example, 404 Not Found, 400 Bad Request, 401 Unauthorized, etc.
  • The anchor text associated with each link.
  • Source pages where the broken link appears.
  • Destination URLs for the linked resources.
Starting page of the Google Search Console.

Once the affected links are identified, apply the appropriate fix based on the actions outlined in Steps 2 and 3. This can include:

  • Correcting URL syntax errors or typos.
  • Updating URLs.
  • Establishing redirects for missing or renamed content.
  • Removing links entirely if there is no replacement content.

Performing these audits regularly ensures that search engines crawl and index your website properly.

Step 5: Create Custom 404 Pages

A 404 error cannot always be avoided. A well-designed error page helps users understand what went wrong and encourages them to stay on your website rather than leave.

An engaging 404 error page should include the following elements:

  • A clear message (Page not found).
  • A link to the homepage.
  • A search bar.
  • Suggested or popular pages.
  • Branding and tone that reflect your company's values and style.
Example of 404 error page.

Custom 404 Page in WordPress

CMS platforms, like WordPress, have built-in support for custom 404 error pages. Typically, the page design matches the website's active theme.

The default page, 404.php, is in the active theme's root directory:

/wp-content/themes/your-theme-name/404.php

You can manually edit the file and customize the page even further. For a no-coding solution, look to theme builders or plugins that help users design 404 error pages in a visual, user-friendly environment, such as Divi, Elementor, or 404page.

Custom 404 Page (Apache)

Web admins running a website on an Apache web server can configure a custom 404 page in the .htaccess file.

To set up a custom 404 page in Apache:

1. Use an FTP client, cPanel, or a terminal to access the server's root directory.

2. Open the .htaccess file in a text editor and add the following line:

ErrorDocument 404 /custom-404.html

3. Place the custom error page in the web root directory:

/var/www/html/custom-404.html

The path in ErrorDocument must be relative to the document root and point to the location of the error file.

Step 6 (Optional): Troubleshoot 404 Errors in API Requests

When your frontend code or an external system sends an API request, the server returns a 404 Not Found error if it cannot locate the requested resource. This may happen because the request URL is incorrect, the object is missing or has been moved, or the backend service is not routing the request correctly.

To troubleshoot API-related 404 errors, refer to the sections below.

Verify the Request URL and Resource ID

By testing the endpoint outside of your application, you can determine if there is an issue with the frontend, network, or backend logic.

1. Use tools like Postman or curl to recreate the API call manually. For example, the following request targets a specific object:

curl -i -X GET https://api.ccbill.com/v2/payment-token/xzy1DRT9opsiauensba

The API returns a structured 404 error message in JSON or XML. In this example, the response indicates that the request reached the backend but that the specified object (token ID) does not exist or is inaccessible.

{
  "status": 404,
  "message": "Token not found",
  "path": "/v2/payment-token/xzy1DRT9opsiauensba"
}

2. Test the same endpoint without the object ID to verify that the base route is functional:

curl -i -X GET https://api.ccbill.com/v2/payment-token

If the server returns a 200 OK, the path is valid, and the issue is likely with the resource ID.

3. To confirm whether the resource exists, query your database or service layer. For example, to check for the entry in MySQL, enter:

SELECT * FROM tokens WHERE id = 'xzy1DRT9opsiauensba';

4. If the object is missing or deleted, the 404 response is valid. If the object does exist, proceed to check other potential causes. Double-check the URL path and compare it against the API documentation.

Look for:

  • Typos in the endpoint path or resource ID.
  • Missing or extra path segments.
  • Incorrect version numbers (e.g., /v1.9/ vs /v2.1/).
  • Incorrect HTTP methods, such as using POST instead of GET.

Check Authentication and Authorization

Some APIs return a 404 Not Found error to unauthorized users, even if the resource exists, as a security precaution. Verify that the authentication token is valid and that the user has permission to access the resource.

Check Backend Routing and Application Logic

If the request reaches the server but still returns a 404 error, it may be caused by a misconfigured backend application or web server.

Confirm that:

  • The endpoint exists and is correctly defined in your application framework, such as Django (Python), Express (Node.js), or Laravel (PHP).
  • The route is registered and enabled.
  • The request is not being blocked by middleware, a proxy, or access control logic.

If the 404 error originates from the server or backend application logic, also check your web server and application error logs. On Linux, you can monitor logs in real-time using the tail command:

sudo tail -f /var/log/apache2/error.log

The following table lists popular web servers and frameworks and their default error log locations:

PlatformLog File LocationExample Log Entry
Apache/var/log/apache2/error.log[error] [client 192.168.1.10] File does not exist: /var/www/html/v2/payment-token/xzy1DRT9opsiauensba
NGINX/var/log/nginx/error.log2025/06/17 12:45:01 [error] 2048#0: *123 open() "/v2/payment-token/xzy1DRT9opsiauensba" failed (2: No such file or directory)
ExpressConsole, Winston, PM2, or custom logs<code>[2025-06-17T14:12:53.452Z] GET /v2/payment-token/xzy1DRT9opsiauensba 404
Error: Token not found
Django/var/log/syslog or a custom directory<code>ERROR 2025-06-17 14:33:21 Not Found: /v2/payment-token/xzy1DRT9opsiauensba
Http404: Token not found
FlaskConsole, WSGI server output, or custom logs<code>2025-06-17 14:40:09,824 - ERROR - 404 Not Found: /v2/payment-token/xzy1DRT9opsiauensba
TokenNotFound: Token not found
Laravelstorage/logs/laravel.log[2025-06-17 14:15:55] local.ERROR: NotFoundHttpException: No route found for GET /v2/payment-token/xzy1DRT9opsiauensba

Compare the timestamp with the time the user reported the error. Look for:

  • Typos in the route name or dynamic parameters.
  • Confirmation that the route handler or controller was executed.
  • Any messages about denied access, missing routes, or misconfigured middleware.

Fix any issue you identify and test the endpoint again using curl, Postman, or your frontend interface:

curl -i -X GET https://api.ccbill.com/v2/payment-token/xzy1DRT9opsiauensba

If the request is successful, the server returns a 200 OK status and a valid response object:

{
  "status": 200,
  "token": "xzy1DRT9opsiauensba",
  "expires": "2025-07-17T15:30:00Z",
  "type": "single-use",
  "customerId": "u456789",
  "createdAt": "2025-06-17T14:15:33Z"
}

Continue to monitor your logs to ensure the error no longer appears.

How to Prevent 404 Errors?

To reduce the chance of the 404 error occurring, take the following precautions:

  • Audit the website regularly. Use tools like Google Search Console, Screaming Frog, or Ahrefs to identify broken links. Content management systems, such as WordPress, support plugins that scan websites, identify crawl issues, and detect missing pages early.
  • Set up proper redirects. In a CMS, use plugins, like Redirection, to manage URL changes without editing server files. On Apache and NGINX servers, configure server-side redirects in .htaccess or nginx.conf config files.
  • Maintain consistent URL structures. Do not update slugs, folder names, extensions, or premalinks unnecessarily. On platforms like WordPress, altering permalink settings can simultaneously break multiple URLs.
  • Update internal links when making changes. Manually update links, navigation bars, and menus if a URL is no longer valid. CMS users should also review widgets, shortcodes, and custom fields that reference the old path and update them accordingly.
  • Manage deleted content. Before removing a page, check if it receives traffic or has backlinks. If the content is no longer needed, redirect the URL to a relevant page rather than leaving it broken.

Conclusion

This article explained what causes the 404 Not Found error and outlined practical steps to resolve it, whether you are a website visitor or a site administrator.

If you manage a WordPress website, find out how to troubleshoot the WordPress 500 Internal Server Error.

Was this article helpful?
YesNo