Troubleshooting and fixing 404 errors on a self hosted WordPress

After hosting my website on Plone and attempting to host it on plain HTML5 I decided that time has come for me to use a CMS. As I wrote in the Hello World post (i.e. the first post) I chose to use WordPress. I installed it and as my work and life made me busier and busier, I kind of ignored. It is very apparent from the irregularity of the posts and blank periods in the posting.

Anyhow, the point is that I didn't realize that the permalinks, categories and tags were not working. When I clicked on a particular post or tags or categories, it showed me a 404 error. So essentially I had a broken site on my hands. And here I was wondering why my site was not coming up in searches and why I was not getting any traffic. SEO helps Google to crawl and index the website most effectively when permalinks, tags and categories are setup correctly.

Apparently, it is a very common error in WordPress with a very straight forward solution. A simple google search most likely leads you to the right solution. My objective is not to add to the burgeoning posts of "How to fix 404 errors on WordPress". The objective of this how-to is to address one edge case that will occur when you are trying to host WordPress on your own server/computer.

I followed a lot of posts and almost all of them told me the same thing.

  • Re-save the permalink settings and
  • Ensure you have the .htaccess in your WordPress directory (some of them don't tell that you should have it in the WordPress directory though).

I was at my wits end on what to do to solve the problem. I was about to give up and try and reinstall WordPress when I came across this site and the how-to. That how-to does address the edge case of people like me who like to run their own web servers instead of buying managed hosting. In fact, I am running my site in containers. In fact re-installing WordPress would have added work and would have broken my site. Thankfully I stayed away from it.

The rewrite module of Apache is not automatically enabled. This was the "A-HA" moment for me. I checked out the modules that were loaded by running sudo apachectl -L and sure enough there was no rewrite module enabled there. I double checked that I had the rewrite module binary in the mods-available directory in my Apache distribution.

At this point, I was ready to enable the module by running sudo a2enmod rewrite and sudo service apache2 restart on my server and enable the module. After that, I was able to reset the permalinks to whatever I wanted it to be. This fix also worked tags and categories.

I hope this helps whoever is facing this issue.

29 thoughts on “Troubleshooting and fixing 404 errors on a self hosted WordPress”

  1. An outstanding share! I’ve just forwarded this onto a friend who has been conducting a little research
    on this. And he in fact bought me dinner because I found it for him…
    lol. So let me reword this…. Thank YOU for the
    meal!! But yeah, thanks for spending the time to discuss
    this issue here on your site.

  2. Cool blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple tweeks would really make my blog jump out.
    Please let me know where you got your theme. Thanks

  3. I do consider all the concepts you have presented to your post.

    They are very convincing and will certainly work. Still, the
    posts are very short for starters. May you please lengthen them a little from subsequent time?

    Thank you for the post.

  4. I think the admin of this website is actually working hard for his site, for the reason that here every data is quality based stuff.

  5. I’m really enjoying the theme/design of your website.
    Do you ever run into any web browser compatibility issues?
    A number of my blog visitors have complained about my site not working correctly
    in Explorer but looks great in Chrome. Do you have any suggestions to help fix
    this issue?

  6. I’m impressed, I must say. Rarely do I come across a blog
    that’s equally educative and interesting, and let me tell you, you have hit the nail on the head.
    The problem is something not enough folks are speaking intelligently about.
    I am very happy that I found this in my search for something concerning this.

  7. Having read this I thought it was extremely informative.
    I appreciate you taking the time and energy to put this informative article together.

    I once again find myself personally spending a significant amount of time both reading
    and commenting. But so what, it was still worth it!

  8. you are in reality a good webmaster. The site loading pace is incredible.
    It seems that you are doing any unique trick. In addition,
    The contents are masterwork. you’ve done a great activity on this matter!

  9. Simply to follow up on the update of this subject on your web site and would
    want to let you know simply how much I treasured the time you took to produce this beneficial post.

    Within the post, you actually spoke regarding how to really handle this challenge with all comfort.
    It would be my own pleasure to build up some
    more concepts from your web site and come as much as offer
    people what I have learned from you. Thanks for your usual excellent effort.

  10. Do you mind if I quote a few of your articles as long as I provide credit and sources back to your blog?
    My website is in the very same niche as yours and my users would certainly benefit from a lot of the information you provide here.

    Please let me know if this alright with you. Thanks a lot!

  11. magnificent post, very informative. I ponder why the other experts of this
    sector do not notice this. You must continue your writing. I
    am sure, you’ve a huge readers’ base already!

  12. Wonderful blog! Do you have any recommendations for aspiring writers?
    I’m planning to start my own site soon but I’m
    a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option?
    There are so many options out there that I’m totally overwhelmed ..
    Any recommendations? Thanks!

  13. Spot on with this write-up, I really believe that this web site needs far more attention. I’ll
    probably be back again to read through more, thanks for the info!

  14. I’m really impressed with your writing skills and also with the layout on your weblog.
    Is this a paid theme or did you modify it yourself? Anyway
    keep up the excellent quality writing, it’s rare to see a
    nice blog like this one nowadays.

  15. Howdy would you mind letting me know which hosting company you’re using?

    I’ve loaded your blog in 3 different web browsers and I must
    say this blog loads a lot faster then most. Can you recommend
    a good hosting provider at a honest price?
    Cheers, I appreciate it!

  16. Good day! This is kind of off topic but I need some help from an established blog.
    Is it very difficult to set up your own blog?

    I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about setting up my own but I’m
    not sure where to begin. Do you have any points or suggestions?
    Thanks

  17. Have you ever thought about creating an ebook or guest authoring on other sites?
    I have a blog based upon on the same subjects you discuss and would really like to have you share some stories/information. I
    know my readers would enjoy your work. If you’re even remotely interested, feel free to shoot me an e-mail.

  18. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is important and all. However think about if you
    added some great photos or video clips to give your
    posts more, “pop”! Your content is excellent but with images and video clips,
    this site could definitely be one of the greatest in its
    niche. Wonderful blog!

  19. Excellent website you have here but I was curious if you knew
    of any forums that cover the same topics talked about in this
    article? I’d really like to be a part of community where I can get comments from other
    experienced people that share the same interest. If you have any
    suggestions, please let me know. Many thanks!

  20. I don’t even know how I ended up here, but I thought this post was great.
    I don’t know who you are but certainly you’re going to
    a famous blogger if you aren’t already 😉 Cheers!

  21. I’m really impressed together with your writing talents and also with the structure in your
    weblog. Is this a paid subject or did you modify it yourself?
    Anyway keep up the excellent quality writing, it is uncommon to look a nice
    weblog like this one nowadays..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.