how to fix 404 error in wordpress

WordPress 404s: Your Guide to Getting Pages Back Online

How to fix 404 error in wordpress: 7 Easy Steps

What is a WordPress 404 Error and Why Does It Occur?

Your Guide to Fixing WordPress 404 Errors

To how to fix 404 error in wordpress, follow these quick steps:

  1. Reset Permalinks: Go to Settings > Permalinks in your WordPress dashboard and click ‘Save Changes’.
  2. Restore .htaccess File: Regenerate or manually restore your .htaccess file with the default WordPress code.
  3. Disable Plugins/Themes: Temporarily deactivate plugins and switch to a default theme to pinpoint conflicts.
  4. Update Database URL: If all else fails, verify your WordPress URL settings directly in your database.

Encountering a “404 Not Found” error on your WordPress site means the server cannot find the requested page. This is frustrating for visitors and can seriously harm your website, potentially leading to a 20% loss in traffic and damaging your site’s SEO. Fortunately, most WordPress 404 errors have straightforward fixes.

As Kevin Gallagher, I have spent over fifteen years helping businesses keep their WordPress sites running smoothly. My team and I have built over 2500 WordPress websites and manage hundreds more, so we understand the intricacies of resolving these errors and getting pages back online.

flowchart showing common causes leading to a 404 error - how to fix 404 error in wordpress

A 404 error is an HTTP status code indicating the server found no resource at the requested URL. For users, it is a dead end that often causes them to leave your site. For search engines like Google, frequent 404s suggest a poorly maintained website, which can lead to lower rankings and a wasted “crawl budget.”

These errors also cause you to lose valuable “link equity” from backlinks that now point to a non-existent page, impacting your site’s authority.

Common causes for 404 errors in WordPress include:

  • Changed URLs (Permalinks): You updated a page’s URL, but old links still point to the original address.
  • Deleted Content: You removed a page or post without setting up a redirect to guide visitors elsewhere.
  • Corrupted .htaccess File: This critical server configuration file, which manages URL structure, can become damaged.
  • Plugin or Theme Conflicts: A plugin or theme can interfere with how WordPress handles URLs.
  • Site Migration Issues: Moving a site to a new host or domain without updating all URL references can trigger widespread 404s.

Understanding these root causes is the first step in learning how to fix 404 error in wordpress effectively.

When you encounter a 404 error, start with the easiest and most common solutions first. These two steps often resolve the issue without requiring any code and can be done directly from your WordPress dashboard or with a simple file adjustment on your server.

Resetting your permalinks is often the quickest fix, especially if your homepage works but other pages or posts show a 404 error. This action forces WordPress to refresh its URL rewriting rules, ensuring the server correctly interprets your site’s addresses.

WordPress permalink settings screen - how to fix 404 error in wordpress

Here is how to fix 404 error in wordpress by resetting permalinks:

  1. Log in to your WordPress Dashboard (usually at yourdomain.com/wp-admin/).
  2. Steer to Settings > Permalinks in the left-hand menu.
  3. Without making any changes, scroll down and click the Save Changes button.

This simple action regenerates your .htaccess file and often resolves 404 errors across your site. If the errors persist, try changing your permalink structure to “Plain,” saving, and then changing it back to your preferred structure (like “Post name”) and saving again. This can provide the extra nudge WordPress needs.

Step 2: Restoring the WordPress .htaccess File

The .htaccess file acts as a traffic controller for your web server, directing visitors to the correct pages using your “pretty permalinks.” If this file is corrupted, missing, or contains incorrect rules (often due to a plugin or manual error), it can cause 404 errors on your posts and pages.

Here is how to fix 404 error in wordpress by restoring your .htaccess file:

  1. Connect to your server using an FTP client (like FileZilla) or your host’s File Manager (in cPanel).
  2. Locate the .htaccess file in the root directory of your WordPress installation. You may need to enable the “show hidden files” option to see it.
  3. Make a backup by downloading the file and renaming it (e.g., htaccess_old.txt).
  4. Delete the .htaccess file from your server.
  5. Return to your WordPress Dashboard, go to Settings > Permalinks, and click Save Changes. WordPress will automatically generate a new, correct .htaccess file.

For most standard WordPress sites, the default .htaccess code is:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

You can use this code to create the file manually if needed. For more complex setups, refer to the official WordPress .htaccess support page.

Deeper Dive: How to Fix 404 Error in WordPress with Advanced Troubleshooting

If resetting permalinks and the .htaccess file does not resolve the 404 errors, it is time for more advanced troubleshooting. This involves methodically checking for plugin or theme conflicts, incorrect file permissions, and database setting errors. For more guidance, see our WordPress Troubleshooting resources.

Step 3: How to fix 404 error in WordPress by disabling plugins and themes

Plugins and themes can sometimes interfere with WordPress’s URL rewriting functions, causing 404 errors. A systematic deactivation process can help you identify the source of the conflict.

Here is how to fix 404 error in wordpress by checking for conflicts:

  1. Deactivate All Plugins: If you have admin access, go to Plugins > Installed Plugins, select all, and choose “Deactivate” from the bulk actions menu. If you cannot access your admin area, use an FTP client or File Manager to steer to the wp-content/ folder and rename the plugins folder to plugins_old. This deactivates all plugins.
  2. Check Your Site: See if the 404 errors are gone. If they are, a plugin was the cause.
  3. Identify the Culprit: Reactivate your plugins one by one, checking the site after each activation. When the 404 error returns, you have found the problematic plugin. You can then find an alternative or contact the developer for support.
  4. Check Your Theme: If plugins are not the issue, your theme might be. Go to Appearance > Themes and activate a default WordPress theme (e.g., Twenty Twenty-Four). If this fixes the error, your theme is the problem. You may need to contact the theme developer or switch themes.

For more on this process, read our guide on Debugging in WordPress.

Step 4: Correcting File and Folder Permissions

Incorrect file and folder permissions can prevent your web server from accessing the necessary files, resulting in a 404 error. The server reports the file as “not found” because it does not have permission to read it.

Standard permissions for WordPress are:

  • Directories (folders): 755
  • Files: 644

To check and correct permissions, access your site via an FTP client or File Manager. Right-click on the main WordPress folders (wp-admin, wp-content, wp-includes) and files (index.php, .htaccess) to view and set their permissions to the correct values.

Step 5: Updating the WordPress URL in the Database

If you have recently migrated your site to a new server or domain, incorrect URL settings in the database are a likely cause of widespread 404 errors. WordPress stores the siteurl (where core files are) and home (the site’s public address) values in the database.

Here is how to fix 404 error in wordpress by updating these URLs:

  1. Access your database using phpMyAdmin from your hosting control panel.
  2. Select your WordPress database and open the wp_options table.
  3. Find the rows with the option_name of siteurl and home.
  4. Edit the option_value for both rows to reflect your correct site URL (e.g., https://www.yourdomain.com).

This method is especially useful if you are locked out of your admin area due to URL issues. For more help, consult our WordPress Database Error guide.

Proactive Management and Specific Scenarios

After fixing existing 404 errors, the next step is proactive management to prevent them in the future. This involves implementing strategies for content changes and handling specific environments, such as a local development server, to maintain strong SEO and a smooth user experience.

Step 6: Setting Up 301 Redirects for Moved or Deleted Content

Redirection plugin interface - how to fix 404 error in wordpress

A 301 redirect is a permanent instruction that tells browsers and search engines a page has moved to a new location. It is essential for preventing 404 errors and preserving SEO value when you delete a page, change a URL, or merge content.

By redirecting old URLs to new ones, you pass on the “link equity” from backlinks and ensure users who click old links are seamlessly guided to the correct content.

The easiest way to manage redirects is with a plugin like the Redirection Plugin.

  1. Install and activate the plugin from the WordPress directory.
  2. Steer to Tools > Redirection in your dashboard.
  3. Click “Add new redirection.”
  4. Enter the old, broken URL in the “Source URL” field and the new destination in the “Target URL” field.
  5. Click “Add Redirect.”

This plugin can also monitor for new 404 errors, allowing you to fix them quickly.

Alternatively, you can add redirects directly to your .htaccess file. Always back up the file before editing. To redirect a single page, add this line:
Redirect 301 /old-page-slug/ https://www.yourdomain.com/new-page-slug/

Consistently using 301 redirects is a key part of learning how to fix 404 error in wordpress for good.

Step 7: Fixing 404 Errors on a Local WordPress Installation

Local development environments (using tools like WAMP, XAMPP, or MAMP) are great for testing, but they can present unique 404 challenges. The most common issue is that the Apache server’s mod_rewrite module, which is necessary for WordPress’s “pretty permalinks,” is not enabled.

Here is how to fix 404 error in wordpress on a local setup:

  1. Enable mod_rewrite: In your WAMP/XAMPP/MAMP control panel, find the Apache settings and ensure the rewrite_module is enabled. If not, you may need to edit the httpd.conf file manually. Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the # to uncomment it. Also, find the <Directory> block for your web root and change AllowOverride None to AllowOverride All.
  2. Restart Apache: After making changes, you must restart the Apache server for them to take effect.
  3. Reset Permalinks: Log in to your local WordPress dashboard, go to Settings > Permalinks, and click Save Changes to regenerate the .htaccess file with the correct rules for your local environment.

When to Call for Professional WordPress Support

Even with a detailed guide, some WordPress 404 errors can be particularly stubborn. If you have tried all the troubleshooting steps and the “Page Not Found” messages persist, it may be time to call for professional WordPress support.

It is wise to contact experts when you encounter these situations:

  • Persistent Errors: You have exhausted all the common solutions, but the 404s will not go away. This often indicates a deeper, more complex issue with your server configuration or a hidden conflict.
  • Complex Server Issues: If the problem appears to be at the server level (Apache, Nginx) and you are not comfortable editing server configuration files, a professional can safely diagnose and resolve the issue.
  • Lack of Technical Confidence: If you are worried about making a mistake while editing critical files like .htaccess or the database, it is better to let an expert handle it to avoid causing bigger problems.
  • Time is Money: For a business website, downtime means lost visitors and revenue. A professional support team can diagnose and fix issues much faster, minimizing the negative impact.
  • Limited Hosting Support: If your hosting provider states the problem is a “website issue” and not on their end, you need a dedicated WordPress specialist.

At wpOncall, we specialize in WordPress website security and support. Our Santa Rosa, CA-based team provides daily updates, backups, and unlimited support to resolve issues quickly. We have deep expertise in all things WordPress and pride ourselves on fast response times. If you need urgent assistance with a stubborn 404 error, our Emergency WordPress Support services are designed to get you back online efficiently. Do not let 404s cost you traffic or peace of mind; let us handle the heavy lifting.

Frequently Asked Questions about WordPress 404 Errors

We have covered many solutions for how to fix 404 error in wordpress, but some specific scenarios can still be confusing. Here are answers to some frequently asked questions.

Why is my WordPress admin dashboard showing a 404 error?

Getting a 404 error on your wp-admin login page is alarming because it blocks you from accessing your site’s backend. This issue typically points to one of three problems: incorrect file permissions, a corrupted .htaccess file, or URL setting issues after a site migration.

To regain access, try these steps:

  1. Check File Permissions: Use an FTP client to ensure your wp-admin directory is set to 755 and the files within it are 644.
  2. Restore Your .htaccess File: Temporarily rename your main .htaccess file. If you can then access your admin dashboard, go to Settings > Permalinks and click “Save Changes” to generate a new one.
  3. Verify Database URLs: Use phpMyAdmin to check that the siteurl and home values in your wp_options table are correct.

How do I fix 404 errors for custom post types?

Custom post types (CPTs), such as “Products” or “Portfolios,” can sometimes cause 404 errors if their URL rewrite rules are not properly registered with WordPress. This often happens after creating a new CPT or changing its settings.

The fix is usually simple: flush your permalinks. Go to Settings > Permalinks in your WordPress dashboard and click Save Changes. You do not need to change any settings; this action forces WordPress to update its URL structure to include your CPTs. If the problem continues, double-check the CPT registration code in your functions.php file or plugin to ensure the rewrite and has_archive arguments are configured correctly.

Can I create a custom 404 page to improve user experience?

Yes, and you absolutely should. A custom 404 page turns a frustrating dead end into a helpful, on-brand experience. Instead of a generic error message, you can guide lost visitors back to your content, reduce your bounce rate, and maintain a professional look.

To create one, you can either edit your theme’s existing 404.php file or create a new one in a child theme. WordPress will automatically use this file for any 404 errors.

Your custom 404 page should include:

  • A friendly message explaining the page could not be found.
  • A search bar to help users find what they were looking for.
  • Links to your homepage, popular posts, or key pages.
  • Contact information or a form to report the broken link.

A thoughtful custom 404 page improves user experience and shows visitors you care, even when an error occurs.

Get Your WordPress Site Back on Track

In this guide, you have learned how to fix 404 error in wordpress, from simple permalink resets to advanced database edits. Most 404 errors are fixable with a patient and methodical approach. You now have a clear roadmap to diagnose and resolve these common issues.

However, fixing errors is only half the battle. The key to a healthy website is proactive maintenance. Just as you would service a car to prevent a breakdown, you should regularly maintain your website to prevent errors.

  • Regular Monitoring: Use tools like Google Search Console to find and fix broken links before they become a major problem.
  • Implement 301 Redirects: Make it a habit to set up redirects whenever you delete content or change a URL. This preserves your SEO value and ensures a smooth user experience.
  • Keep Everything Updated: Regularly update your WordPress core, themes, and plugins to patch security holes and fix bugs that could cause issues.

Managing a WordPress site can be time-consuming, especially when technical problems arise. That is why wpOncall exists. We take the technical heavy lifting off your plate so you can focus on your business. With our daily updates, automatic backups, and unlimited support, we ensure your site remains secure, fast, and error-free. When a 404 error appears, you can simply contact us, and our expert team will handle it.

If you are struggling with persistent 404 errors or want to ensure your site is properly maintained, we are here to help. Our Fix WordPress Errors Guide offers even more solutions for common WordPress problems.

Your website deserves to be online and welcoming visitors, not frustrating them with errors. Take action today to get your pages back online and keep your visitors happy. If you need a helping hand, wpOncall is ready to take the worry out of WordPress management.