Can't listen on anything but localhost (ASP MVC Framework IIS Express)

James Baron 21 Reputation points
2020-08-08T01:46:51.657+00:00

I'm unable to get a .Net Framework MVC project to listen on anything except localhost.

If I change

      <IISUrl>http://localhost:2319/</IISUrl>

to

      <IISUrl>http://eadev:2319/</IISUrl>

my project won't even load.

I get the following error:

Creation of the virtual directory http://eadev:2319 failed with the error: Cannot create the Web site 'http://eadev:2319'. You must specify "localhost" for the server name.

I've seen just tons of issues on this, and someone in my own company has this working, but I cannot get it to work. I actually set him up. And I still can't do this.

I've tried

netsh http add url=http://eadev:2319 users=everyone

That just gives me access denied errors when I run it from the console, but it's still trying to load localhost:2319

I deleted the .vs directory. I added entries to the .vs/app/config/applicationhosts.config

I've added eadev to the hosts file.

Also, one thing that used to work is that I downloaded nginx for Windows and setup a reverse proxy, but now it just says bad gateway. I even setup an ssh tunnel. I'm assuming now it's being picky about headers. I can access http://localhost:2319, but not nginx proxy_pass http://localhost:2319 is now giving bad gateway, but it used to work. If I point the proxy_pass to http://example.org it works.

Edit: I found out that nginx is resolving to 127.0.0.1 and IIS Express just won't respond.

There are just so many answers to this and other people seem to have got it working, but I cannot.

Visual Studio Setup
Visual Studio Setup
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
952 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Cheong00 3,466 Reputation points
    2021-01-08T02:36:24.38+00:00

    First, IIS Express is intentionally written to bind on localhost only. And it's not related to "netsh http". (Actually it has a number of other hard-coded things that "get into the way" too, say it will not allow you to return customized error message of error HTTP status codes and so on, so I strongly recommands you to develop on IIS if you're not using Home editions of Windows)

    Second, regarding the use of NGINX, I don't know why you can't make it work, but I used that and it works flawlessly.

    Just to remind you that the port NGINX listen on should not be the same as IIS Express, or you'll need to use IP number instead of hostname.

    0 comments No comments