Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

How to Fix WordPress Posts Returning 404 Error (Step by Step)

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Are your WordPress posts returning a 404 error on your website?

This error happens when you can access your WordPress admin area and blog, but when you try to open a post, you will see “404 Not Found.”

In this article, we will show you how to fix WordPress posts returning 404 errors.

How to fix WordPress posts returning 404 error

Why Are My WordPress Posts Returning a 404 Error?

There are several reasons why your WordPress posts might be showing a 404 “Page Not Found” error. These can include:

  • Plugin or theme conflicts: Sometimes, plugins or themes you’ve installed on your site can interfere with how WordPress handles permalinks. This can lead to broken links and 404 errors.
  • Custom code issues: If you’ve added custom code to your website, there might be errors in the code that are affecting permalinks or causing other conflicts, resulting in 404 errors for your posts.
  • Issues with your .htaccess file: The .htaccess file plays a role in how WordPress structures URLs. If this file is corrupted or missing, it can lead to 404 errors for your posts.

That being said, let’s look at how to fix WordPress posts returning 404 errors. You can use the links below to jump straight to different solutions:

Don’t want to fix 404 errors yourself? WPBeginner Pro Services can help! With our affordable Emergency WordPress Support, you can hire experts to fix 404 errors, broken links, redirect issues, and much more. Stop stressing over WordPress issues and get them fixed! Schedule Emergency WordPress Support Services today!

Video Tutorial

Subscribe to WPBeginner

If you prefer written instructions, then just continue reading.

Method 1: Check for Plugin or Theme Conflicts and Custom Code Issues

Sometimes, plugins, themes, or custom code you’ve added to your WordPress site can interfere with permalinks or cause conflicts, leading to 404 errors. We’ve even experienced it ourselves when we’re testing tools on our demo site.

One way to solve this problem is to temporarily deactivate plugins. Plugins can sometimes disrupt how WordPress handles links.

Once you’ve deactivated the plugins, you can reactivate them one by one while checking if the 404 error reappears after activating each plugin. If the error shows up after activating a specific plugin, that might be the culprit.

You can then search for solutions related to that plugin or contact the plugin developer for support.

Similarly, your WordPress theme might be causing the conflict.

To check, you can temporarily switch to a default WordPress theme like Twenty Twenty-Three or Twenty Twenty-Four. All you need to do is go to Appearance » Themes and click ‘Activate’ on a default theme.

Activating a default WordPress theme

If the 404 error disappears with the default theme, it indicates a potential conflict with your current theme. You can then try troubleshooting the theme or consider using a different theme.

You can check out our expert pick of the most popular WordPress themes for recommendations.

If you’ve recently inserted code snippets to your website, there might be errors in the code causing the 404 errors. Take a close look at the code you added and see if you can identify any mistakes.

The safest way to add code snippets to WordPress is with the WPCode plugin. This plugin lets you insert custom code without directly working with the theme files, reducing the risk of breaking your website.

Plus, whenever WPCode spots an error in your code, it will automatically deactivate the snippet and ask you to check it. You can also use the testing mode to check if your code works before pushing it to your live website.

WPCode error warning

If none of these solutions work, move on to the next method where we’ll troubleshoot your permalink settings.

WordPress posts can return 404 errors because of problems with rewrite rules in your .htaccess file. In most cases, you can fix the problem by updating your permalink settings.

Simply go to Settings » Permalinks in your WordPress admin, and click on the ‘Save Changes’ button.

Check Permalinks

There is no need to make changes to the permalink settings themselves. This will update your permalink settings and flush the rewrite rules.

In most cases, this solution fixes the WordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.

Method 3: Update the WordPress .htaccess File

Before you start, make sure to back up your WordPress .htaccess file first. If something goes wrong, you can easily restore the original file.

Now, you will need to connect to your server using an FTP client like FileZilla or the File Manager app in your WordPress hosting dashboard.

Next, you will need to find and edit the .htaccess file, which is located in the same location as folders like /wp-content/ and /wp-includes/.

Simply right-click on the file and select ‘File permissions.’

.htaccess file permissions

You can make the file writeable by changing its permissions to 666.

Simply enter ‘666’ into the ‘Numeric value’ box and then click on ‘OK’.

Change file attributes for the .htaccess file to 666

Then, you need to repeat the steps in the first method of our tutorial. Once you have done this, don’t forget to change the permissions back to 660.

You can also edit the file and add code to it.

Edit .htaccess file

Once you have opened the .htaccess file with a text editor, simply insert this code:

# 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]
# END WordPress

Method 4: Contact Your Hosting Provider

If neither of the solutions above has fixed the WordPress posts returning 404 error, then we recommend contacting your WordPress hosting provider. There may be an error on their end, or they might be able to help you troubleshoot the problem.

Please also see our guide on how to properly ask for WordPress support and get it.

Method 5: Fix WordPress Posts Returning 404 Error on Local Servers

If you are using a local server for testing purposes, then you will need to enable mod_rewrite in the Apache configuration of your MAMP, WAMP, or XAMPP site.

This will allow WordPress to generate clean URLs and prevent the 404 error for posts and pages on your local server.

How you do this will differ by the platform you use. People using XAMPP can open their control panel and click the ‘Config’ button within Actions. Then, select ‘Apache (httpd.conf).’

The Apache (httpd.conf) menu on XAMPP

Next, you will need to find this line #LoadModule rewrite_module modules/ and remove the ‘#’ to uncomment it.

This will load the mod_rewrite.

Finding the rewrite_module on httpd.conf file

Then, find all instances of AllowOverride None and change them to AllowOverride All.

The ‘All’ value means that all directives can be overridden.

Changing AllowOverride None to AllowOverride All

Once done, you can save the httpd.conf file and close it. After that, in the XAMPP control panel, click ‘Stop’ on the Apache module and ‘Start’ again to restart it.

Then, go back to your admin dashboard to see if your permalinks are working.

We hope this article helped you resolve the posts returning 404 errors in WordPress. You may also want to see our guide to the most common WordPress errors and how to fix them, along with our expert picks for the best WordPress plugins to grow your site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

773 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Kaycee says

    Hi. Really nice article.

    I had a 500 internal server error issue with my site when I tried using the W3 Total Cache plugin.

    To fix this, I renamed the .htaccess file to .htaccessbak. After doing this, I noticed that the 500 error cleared but then I got a 404 error! All the links and pages on my site returned a 404.

    On the All Pages section, I see a link that says “Purge from cache”

    Please what do I do to clear this issue?

  3. Karma says

    I tried to follow your direction in fixing my problem, it took for about a day, but I didn’t find the good result.

    Then I gave up and contacted my hosting. And it fixed only in 5 minutes. Lol the problem came from the hosting…

  4. Mark Kay says

    By careful with post variables names. I had a contact form with an input field called “name”, that caused WordPress to show the 404 page. Took me a long time to figure out the problem. I fixed it be changing the field name from “name” to “your-name”.

  5. Ramzan says

    My problem is that I m going to wp adminin
    And want to edit post it is not going in edit mode of post and page gives me error page not found 404 but my site and its pages are opening well in browser
    Plz guide me I can solve this problem

  6. Sunit says

    Hi, I have tried following the above steps but my issue is this: when I visit my website directly by putting typing the url, then it works fine. But, when i type in my site url in google search box and then click on the link from the search results, I get the 404 error or message saying “your connection is not private”.
    My website is but google search result shows it as

    So not sure what the issue is. I used to have but now I am dong self-host using HG.

    Any help will be appreciated.

  7. Michaela says

    hi, I tried first solution, nothing happened. I wanted to try the second, but I cannot find the .htaccess file. Not in FTP, not even in my WP online editor. I had this issue today for the first time. I use WPML plugin, until now everything went without problem, but today my translated post in English throws this 404 Error. Any idea what shall I do if I cannot locate the .htaccess file?

  8. Shirish Dhungel says

    Well thanks! I remember, that WP Super Cache official stated to remove rewrite code from .htaccess. After that, my posts redirected to 404. Thanks to you, now my site is perfectly fine.

  9. Akhelesh says

    Do I have to remove the code snippet I added to htacces file after my problem has been solved?

  10. Rohan khamkar says

    Sir, when I post a new post it gives me error that 404 page not found. Previously everything was fine but when I add a new user and give him a role of administrator from that time I can’t post new post. Any solution Please. Thank you in advance.

    • WPBeginner Support says

      You should never give administrator role to a user you don’t trust. You can always change back their role by going to Users page and then clicking on the Edit link below the user that you want to change. After that you check your site’s permalink structure. See if they installed any new plugin and if they did, then deactivate that plugin.


  11. R Donahoo says

    Didn’t work on my apache server. Had an additional step to allow mod_rewrite to actually work. Edit your httpd.conf file and add ‘Allowoverride all’. For example:

    DocumentRoot /var/www

    find the section that sets up the directory options, such as:

    Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    allow from all

    add Allowoverride all

    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all

    save and restart the web server to re-read the updated configuration.

    All was well after that.

    Thanks for your useful post moving me into the right direction.

  12. Eva says

    I found the some problem. However, I could not log in to the admin page. Could you give solution to mitigate this problem?

  13. Rachit Sharma says

    but not working for me when i updated permalink with post name and change .htcces file but not worked. any other solution for that.

  14. Ahsan says

    Wowww Thank you so much, that was really helpful.
    In my case it was WAMP server, after turning on “rewrite module” in apache, my problem was solved.

  15. Kailash says

    Wow – this still works. Done a search on google and found articles in wordpress but this was by far the simple-est and bang it works.

    Thanks a mill – saved me a heap of time

  16. Shawn Ritch says

    Hello and thanks for all the useful tips. Unfortunately, this tip didn’t work for me. I re-saved my permalinks in WordPress settings (didn’t work) so then I tried your next method and it didn’t work either. I’m thinking the reason for this is because I have different permissions. My original permission is 644. When I change permission to 660 none of my pages work so I believe the 666 permission is wrong as well. I’m using a Go Daddy server if that helps any :/

    I’m at a loss and have no idea what to do from here. However, I can’t afford to have pages that don’t work. Any suggestions would be greatly appreciated.

    Shawn Ritch

  17. Hannah Brown says

    Thanks, yours was the only place that told me HOW to fix my broken links! You’re the best

  18. Chris says

    How do I fix the issue when I upload a new plugin and then my categories, not posts, become 404?

  19. Bob says

    This is great advice. I thought I was going to have to take a deep dive, but two clicks and I’m GTG. Thanks!

  20. Ronn Reason says

    i keep getting this message with my email account;

    Error Oops… a server error occurred and your email was not saved. (#404)

    Please advise ASAP

  21. Steve says

    I had this problem after moving sites to a new server. Default Permalinks worked, but not the settings I was using.

    I needed the apache server to “Allow Override” for the htaccess file to take effect.

  22. Vivek says


    I need a little help regarding 404 error.

    I am getting 404 error in my Page 2 section.

    I have googled a couple of times. but did not get the solution.

    Could you please tell me what is the reason for it?

  23. Rudy says

    My site links will work ONLY after I’ve VIEWED the permalink settings, without any changes, and Voila! The links work again. What is causing this and how can I program this instead of having to log in?

    I’ve tried the following commands in WP-CLI to no avail:

    wp rewrite flush –hard –path=c:\xampp\htdocs\mywordpress

    wp cache flush –path=c:\xampp\htdocs\mywordpress

  24. Patrick says

    Thanks man, just pressing the “Save changes” on the permalink-settings page did it for me! Cheers!

  25. Amanda says

    Hi there,

    About an hour ago I was able to remedy a pesky ‘500 Internal Service Error’ by following your sage advice and renaming the .htaccess file to .htaccess_old. I was immediately able to access my wp-admin area–and I thought–get going again.

    Unfortunately, something happened which rendered all of my other pages unfindable; each kicking a 404 error.

    I attempted the steps you provided above, but to no avail. Might you have any further suggestions?

    Thank you.

  26. mehdi says

    why i coudl not see my post?
    after I send a post my preveous posts appear.
    it made me crazy please remove previous post

    I found a solution to my problem and will say in next post

  27. mehdi says

    Hello agin
    thank you for this useful article/ I found a bug in wordpress in rtl language in displaying permalink
    I read your article and encourage to solve the problem with your contribute.
    my problem in detail:
    1-I created a mysql database(in utf8 general ci)
    2-I installed last wordpress versin(locally) and install my theme(multiup v 1.2 from themeforst)
    3-Next I did import demo as whele.
    in the theme admin panel exixst category portfolio (in this section we create our category with name and slug) then in all post under portfolio section we can create our posts and determine category of post from portfolio category) finally in homepage we have a section that shows portfolio post in category(with their picture)
    In english slug and name the category of portfolio show well but when i change category in portfolio category( slug) into rtl language the category in homepage canvert into charachter like base 64(I think that my slug convert into ansi ie each character convert into 6 charachter)
    How I can overcome my problem?I think I must avoid change slug or show slug into utf8 or unicode . I am beginer in wpordpress , If I khnew wordpress more I could solve this simple problem .Any one with khnowledge of handling hoock and filter and plugin and wordpress can solve this permalink problem . I sure I will solve this problem with your help.
    I tried the second way you offer (that phpmyadmin in utf8generalci) but it doee not work for me.
    before thansk a lot for helping me.I followed your posts regularly .
    1- first I did the trick in above article (this is so good but didnot solve my problem)

  28. mehdi says

    thanks to contribute you knowledge to others .my english is not well.excuse me.
    I download a wordpress theme with portfolio link in admin panel that in porftoli section we can define some category with name and slug . in post we can determine category from portfolio.
    in homepage we can display post in portfolio category! all thing is ok but wen i chang name and slug into rtl language the title of a group in home page shows like this %d8%a8%d8%b1%d9%86%d8%af%d8%b3%d8%a7%d8%b2%db%8c
    i did your solution in this topic and that another topic(How To Enable Custom Permalinks) but not woks for my problem!

    • WPBeginner Support says

      This could happen if your WordPress database is not using UTF-8 character encoding. Please make sure that your database is using utf8_general_ci as collation. You can check that using phpMyAdmin from cpanel. Before you make any changes to your database, please create a complete WordPress backup first.


  29. Atula Gupta says

    Thank you so much for fixing my problem in seconds! I was panicking about all my posts giving this error and this solution was so simple! Thanks again.

  30. Sammy says

    Thank you, thank you! This was making me crazy and you just helped me fix it in 2 seconds. High five.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.