0

I am running Visual Studio in a VMWare Fusion virtual machine. When I debug my application, VS makes the application available on localhost:50609. I can use it effectively while in the vm itself. However, I would like to access this running instance from a simulated mobile app running in the host machine (an OsX host). This does not work -- the host simply does not see the running instance on the guest.

I started thinking this had something to do with firewalls or the way that the VM networking was set up. But, long story short, I'm pretty sure that the web application is hosted specifically on "localhost", and therefore is inaccessible outside of the localhost itself. Thus, I cannot use the guest OS's IP address on the virtual network to access the site. That is actually true even within the guest OS; i.e., I cannot access the site by using address 192.168.x.x:50609, but I can access it using localhost:50609 (again, this is from the guest, not the host).

So, I am convinced that VS or IIS (I think it's running IIS Express; whatever comes by default with VS 2013) is set up to only allow connections through localhost. That seems like a very good default for security reasons, but in this instance it's not what I want to do.

Can I make this debugged application accessible to an outside machine?

The fact that this is running using VMs is probably quite irrelevant, but I just wanted to give the specific setup. I've disabled Firewalls to test this, so it's not something like that.

[EDIT] The link pointing to how to do this in Web Matrix is useful, but I still lack the final step for how to change the default address in Visual Studio. I think it's only half the answer.

Yuri
  • 361
  • 2
  • 6
  • IIRC, you need to change the IP address that IIS Express is listening on to `0.0.0.0` in its config file. – SLaks Jun 24 '15 at 18:49
  • Michael Hainc's link is useful, but part of the solution is specific to Web Matrix. I'm not sure what the equivalent is in Visual Studio. – Yuri Jun 26 '15 at 04:43
  • I have a very similar setup and the same problem. I discovered TWO important things: a) edit `Properties/launchSettings.json` to the localhost b) setup the environmental variable ASPNETCORE_ENVIRONMENT="Development" However, I **still** cannot get connected to the running server from the host machine. I have verified on the guest (VM) using `curl` that the server is providing the content. Calling `localhost:5000` from the host machine yields nothing. – Thom Parkin Oct 06 '16 at 18:08

1 Answers1

0

I struggled with this for two days and scoured the interwebs, following several "red herring" leads. On MY system I finally got it working as expected. The key is that Vagrant (Docker) will not properly forward on 127.0.0.1. You need to set the server to listen on '0.0.0.0'. I knew that from my work with Rails in Vagrant. But it was not easy uncovering HOW to specify this in the DotNet CLI (IIS). The answer is that you either add this to the call to WebHostBuilder in 'Program.cs' of your project: .UseUrls("http://0.0.0.0:5000") // Take that, Docker port forwarding!!!

OR call the DotNet CLI like this: ASPNETCORE_URLS="https://*:5000" dotnet run

I settled on a third option. I set an environment variable: ASPNETCORE_URLS="https://*:5000"

Thom Parkin
  • 346
  • 1
  • 9