I would like to connect to my Kestrel server with ASP.NET 5 application hosted on it from another PC in the same network. Is it possible? I can ping my computer from cmd, but I get 'Connection timed out' when I try to connect from a web browser (I type this: "http://{my_kestrel_ip}:5000/").
-
Possible duplicate of [How to specify the port an ASP.NET Core application is hosted on?](https://stackoverflow.com/a/55276201/2934730) – menxin Jul 26 '21 at 03:30
3 Answers
The hosting.ini was not working for us. I have to add this to the project.json file. I believe that the hosting.ini file is being deprecated after Beta8.
--server.urls http://0.0.0.0:5000
or I prefer the following which I believe is less confusing.
--server.urls http://*:5000
So you would end up with something like this in your project.json.
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000",
"ef": "EntityFramework.Commands"
},

- 513
- 5
- 11
-
Yes, I have added my URL to the command description, not the "hosting.ini" file. But the idea of adding this extra (not localhost) URL is what I was looking for. – Pavel Rudko Dec 04 '15 at 21:42
-
Sorry. To clarify 0.0.0.0 in the address field will bind to all IP addresses not just localhost. I found out this weekend that * will also work which my be less confusing. – Blane Bunderson Dec 07 '15 at 14:04
-
This should be the accepted answer. It worked. In addition see [this question](http://stackoverflow.com/questions/34212765/how-do-i-get-the-kestrel-web-server-to-listen-to-non-localhost-requests) for some troubleshooting steps. – AngryHacker Dec 11 '15 at 07:13
In your project folder you should have a file called hosting.ini
. In that file by default you should have something like this:
server=Kestrel
server.urls=http://localhost:5000
You need to make the HTTP server listen on your public IP address as well as localhost. To do that, you can add an additional address by separating them with a semi colon:
server.urls=http://localhost:5000;http://{my_kestrel_ip}:5000

- 113,891
- 12
- 217
- 223
Just did a quick test that seems to work. Create a hosting.json file beside your project.json file.
hosting.json:
{
"server.urls": "http://localhost:5000;http://192.168.1.4:5000"
}
project.json:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --config hosting.json"
},
In a command prompt simply run dnx web
, output:
Hosting environment: Production
Now listening on: http://localhost:5000
Now listening on: http://192.168.1.4:5000
Application started. Press Ctrl+C to shut down.
You'll get a firwall prompt, accept it, and tadaaa!! You can access the site from the LAN and localhost.

- 778
- 1
- 9
- 27