Why does PHP/WordPress on IIS Express keep redirecting all requests to a different port?

I’m using Web Platform Installer and WebMatrix to set up a WordPress site running locally (Windows 7 Professional). It’s the first time I’ve ever used WordPress and the first time I’ve ever used WebMatrix, so it’s possible I’m missing something really basic.

Several times, I’ve had a problem where I hit ‘Run’ in WebMatrix. It opens the browser pointing to the correct URL – http://localhost:10268/ – thinks for a second or two, and then redirects to a different port – in this case, http://localhost:52925/ – which returns ‘This web page is not available’

Read More

I have absolutely no idea where that second port is coming from, or why it’s redirecting. I’ve searched the IIS Express config files (C:Usersdylan.beattieDocumentsIISExpress) and the source code of my WordPress project, but can’t find that port number 52925 anywhere.

Is this a built-in PHP / WordPress thing? Some sort of security feature, maybe? I’m completely stumped. One slightly odd detail – that may well be unrelated – is that I think this only happens after I start using revision control. The site will work fine when it’s first created, but then when I open it from GitHub, things start going weird. Any ideas?

Related posts

Leave a Reply

1 comment

  1. Solved it. It looks like there’s a setting in WordPress that needs to match the IIS Express configuration – and when you check out a site via revision control or set up a new site from an existing folder in WebMatrix, it doesn’t use the same IIS Express settings. In my case, I’d downloaded the code and restored the database from work I’d done earlier on a different machine, and so ended up with IIS listening on port 10268, but the WordPress site configured to listen on port 52925.

    The IIS settings are in C:Usersuser.nameDocumentsIISExpressconfigapplicationhost.config, and the WordPress options are records in the wp_options table where option_name == ‘siteurl’ or ‘home’

    Two ways to fix it that I’ve found:

    1. In WebMatrix, Site, Settings, change the site URL to wherever you’re being redirected to.
    2. Edit the wp_options table and change the settings to match the URL in WebMatrix/IISExpress.