Search This Blog

How to fix: WordPress not opening on localhost:8080 after port change from 80 to 8080 (HTTP 404 Not Found error)


WordPress not opening on localhost:8080 after port change from 80 to 8080
Opening a WordPress site after Apache port change returns HTTP 404 error (Not Found). This is a common issue with  WordPress users who have installed WordPress on local machine, then had to change the Apache HTTP port since other programs took over the HTTP port 80.

Here is a scenario for the issue:

1. XAMPP installed and configured. Apache web page is opening on http://localhost (default port 80)
2. Sites have been developed and placed under /htdocs including say, Drupal and WordPress sites.
3. Drupal and WordPress sites are working fine, and can be accessed on http://localhost/sitename

Now, suppose I needed IIS on the same machine for ASP developments. IIS is installed and it takes over the HTTP port 80. Or even Skype for that matter. Then the Apache HTTP port is changed.

4. Apache HTTP listen port is changed from 80 to 8080 in Apache's httpd.conf file. (See here: How to run Apache and IIS on the same computer)

5. Checked Apache service is starting with no issues using 8080 in the XAMPP Control Panel and the Apache default page opens, now at http://localhost:8080
6. Tested each site one by one - whether they are accessible using the new port 8080.

In my case, all other sites including Drupal sites, seems to embrace the port change well. They can be opened on the new port 8080 by accessing from the URL http://localhost:8080/sitename but not WordPress sites. After the port change, accessing WordPress sites using the url http://localhost:8080/sitename redirects to http://localhost/sitename. The browser returns HTTP 404 (Not found) error.

wordpress localhost 8080 redirect to localhost 404 error

How to make WordPress sites work after changing Apache's HTTP port?

I haven't really dug in to see why WordPress will not work after the port change, but since the WordPress sites were working fine on port 80, but not on the new port 8080, I apply the same steps like I do when moving WordPress sites from local development having port 8080 to live server, that is, localhost URL edits. 

The below steps are also required when moving WordPress site from local machine to live server, if local machine is using port 8080 for Apache.

1. Access phpMyAdmin: http://localhost:8080/phpmyadmin. Log in.
2. Click on the particular WordPress site's database.
3. Export it as SQL
4. Open the exported SQL file in a note editor (such as Notepad ++)
5. Do a Find & Replace:

Find = localhost
Replace = localhost:8080

6. Replace All
7. Save as: Save the file as a new SQL file
8. Back in phpMyAdmin:
phpMyAdmin > structure > select all the tables and drop

[If the edited SQL backup taken earlier is imported without dropping the tables, we get duplicate primary key error due to existing content.]

9. Import the edited SQL backup file
10. Check the WordPress site is accessible from the url http://localhost:8080/sitename

The WordPress site should now be accessible.

wordpress open on localhost 8080




Sponsored Links


3 comments:

  1. Just what I needed. Thank you very much for sharing your experience.

    ReplyDelete
    Replies
    1. @Markus:
      Thanks for the comment. And I am glad it was helpful to you.
      Cheers!

      Delete
  2. Worked for me as well. Thank you very much! :)

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...