How do I get the kestrel web server to listen to non-localhost requests?

appsettings.json urls
configurekestrel core external access
.net core web api change from https to http
now listening on http 0.0 0.0 8080
kestrel useurls
asp net core 3 listen on all interfaces
aspnetcore_urls environment variable

I've deployed my c#, 5, mvc 6 app to a windows 2008 server. I've fired up dnx web and it is listening to port 5000 and works fine when accessing from local computer.

How do I get it to listen to non-localhost requests?

P.S. This question is not a duplicate of refers to pre RC1 when hosting.ini actually had an .ini format. Now, it's JSON and I can't find any documentation on what should actually be in it.

P.P.S. The real solution is in the non-accepted answer to the linked question, with a massive caveat. Steps:

  1. Change your project.json per the linked answer.
  2. Publish your project to your server.
  3. On the server, go to ...\approot\src\YourProject folder and open a command window there.
  4. Run dnx web - it will fail
  5. Run dnu restore
  6. Run 'dnu build`
  7. Run 'dnx web` - the web server should now start fine
P.S. For people upvoting this question. It's outdated. Very badly outdated!

It applied to the early versions of the .NET Core. The question and the answers certainly aren't applicable for the current versions of the framework (e.g. 2.x, 3.x)

Kestrel web server implementation in ASP.NET Core, documentation: Kestrel. Using Kestrel you can specify port using next approaches: Via command line passing --server.urls parameter One should be carefully and not use http://*:5000;http://::5000 , http://::5000;http://*: 5000 , http://*:5000; This website is not affiliated with Stack Overflow. Timeline for How do I get the kestrel web server to listen to non-localhost requests? Current License: CC BY-SA 4.0. 19 events when toggle format

In RC2 the commands section of project.json is no longer used. I haven't gotten Kestrel to pick up the hosting.json yet, but you can programatically set the port in the Main of the application where the new WebHostBuilder is created and configured. Just add .UseUrls() method like in the sample below

    public static void Main(string[] args)
        var host = new WebHostBuilder()


External Network Access to Kestrel and IIS Express in ASP.NET Core, Listen() - Configure addresses for Kestrel server manually using Listen() . don't have to use * , you can use anything that's not an IP Address and is not localhost . If you only want to handle requests from a single hostname, you need to line and one definition for launching the profile using IIS Express. Comment faire pour que le serveur web de kestrel écoute les requêtes non-localhost? j'ai déployé mon c#, 5, mvc 6 application à un serveur windows 2008. J'ai allumé dnx web et il est à l'écoute de port 5000 et fonctionne très bien lors de l'accès à partir de l'ordinateur local.

If you use core 2.1+,modify config section in appsettings.json.

"Kestrel": {
  "EndPoints": {
    "Http": {
      "Url": ""
}, - Kestrel. Configuring Listening Address, Asp.Net Core applications run Kestrel webserver as in-process server to handle web request. As said before, Kestrel is a very light weight webserver that does not have Due to its lightweight nature, Kestrel provides better request processing This will start the app with Kestrel webserver and server will start listening to� When Kestrel starts without any binding customization you get: which clearly shows that it's using the localhost URL. Override the default URLs. In order to expose Kestrel externally you either have to bind to a specific machine name, IP Address or which stands for all IP Addresses (thanks to @DamianEdwards and @BradyMHolt for their help).

If you are trying to put an ASP.NET Core application inside a docker container (which was my use case for needing to listen to non-localhost addresses), note that this use case has already been put together for you by Microsoft. You can see the full glory at

At current (v1.0.1) the key magic for solving this problem is that the source Dockerfile contains a url environment variable setting, and the application does not attempt to override this. (Indeed, a containerized application should internally assert as little as possible about the environment where it will run.)


Note the plus sign rather than asterisk there. I actually recommend visiting the above dockerhub link over reading my answer for as long as the link is good. Version 1.1 is just around the corner, and things may change again in the future.

When running the container, make sure to expose guest port 80, per the environment variable setting. For example:

docker run -d -p 8000:80 myapp
curl localhost:8000

5 ways to set the URLs for an ASP.NET Core app, Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's reverse proxy server receives HTTP requests from the Internet and forwards them to Kestrel after If not using a reverse proxy with host filtering enabled, host filtering must be enabled. Now listening on: 48508. You need to remove all the netsh entries and disable IIS if you want Kestrel to listen on those ports. Kestrel doesn't use netsh/http.sys and can't share ports with it. Copy link Quote reply

Set the environment variable ASPNETCORE_URLS to

If running from Visual Studio, you add the environment variable from the Debug tab of the project properties.

Learn Kestrel Webserver in 10 Minutes, The Universal Dashboard webserver is based on the ASP. desktop apps, like UDForge , that should not open a web server to listen beyond the local machine. Kestrel is an open source, cross platform, light weight and a default webserver used for Asp.Net Core applications. Asp.Net Core applications run Kestrel webserver as in-process server to handle web request. Kestrel webserver is based on async I/O library called libuv primarily developed for Node.js.

[PDF] Kestrel web server implementation in ASP.NET Core, I've deployed my c#, 5, mvc 6 app to a windows 2008 server. I've fired up dnx web and it is listening to port 5000 and works fine when accessing from� Both Kestrel and Node.js are based on libuv. While Node.js exactly states that it uses an event loop, I can't seem to find if such is the case for Kestrel, or if it utilizes thread pooling / request queue like IIS? Kestrel behind a web server. Node.js event loop

Web Server, NET Core supports hosting in IIS and IIS Express, and self-hosting scenarios using NET Core does not directly listen for requests, but instead relies on the HTTP server Kestrel --server.urls http://localhost:5000", "weblistener": " Microsoft. Web server are the machines which serve the client requests .ie browser. Web server has different vendors like kestrel, Apache, IIS etc. it takes HTTP request from client and listen them and send

How do I get the kestrel web server to listen to non-localhost requests?, ASP.NET Core does not directly listen for requests, but instead relies on the HTTP server implementation to surface the request to the application as a set of feature interfaces composed into an HttpContext. While WebListener is Windows-only, Kestrel is designed to run cross-platform.

  • Possible duplicate of ASP.NET 5 Kestrel connect within LAN
  • Well the second answer in the linked question refers to the JSON format. It's not useful for you either?
  • @chuex I tried that, and initially it crashed the web server on startup. Not sure why. Then I did dnu restore, followed by dnu build and then dnx web properly started the web server. I don't know why its happening, but at least I am able to make it work. There is definitely a bug that needs to be addressed before the final release. For now, this is the workaround.
  • I edited by question to reflect the solution.
  • @AngryHacker: You can specify server.urls parameter in application configuration file or command line parameters. The value can have multiple semicolon separated values see here. The file name of configuration can be hosting.json, but it can be not only json: see the issue. --config can be used to specify the config file name
  • In addition you can use "server.urls": "http://*:5000" instead of "server.urls": "" (Personally I think the * makes a little more sense.)
  • @BlaneBunderson: Thank for your suggestion! I have to add that http://*:5000 is the same as http://::5000; and not It force listening for both IPv4 and IPv6. You can verify it by usage http://*:5000;http://::5000 or http://::5000;http://*:5000. One get the error "Microsoft.AspNet.Server.Kestrel.Networking.UvException: Error -4091 EADDRINUSE address already in use" during registering the second address. In some scenarios registering of both IPv4 and IPv6 is good, in another scenarios it's not good. In any way it's good to mention the way.
  • Excellent update for RC2, thanks for the detailed explanation
  • wouldn't .UseStartup<Startup>() override .UseConfiguration(config) in your "update 2" example?
  • there is a typo in that environment variable, it should be ASPNETCORE_URLS
  • This was a big help. I used .UseUrls("http://*:5000") instead, and port forwarded 5000 with empty Host IP on VirtualBox, and finally I can get to the Docker-hosted .NET Core endpoints from my Mac. Sweet!
  • For info on using hosting.json in RC2 and more detailed explanation, read Oleg's answer above, especially "Updated 2"
  • Also applicable to 1.0.0-preview2-003121, docker image
  • This one has also consistently worked for me when running from either VS Code or Visual Studio for Mac. ASPNETCORE_URLS did not work for me
  • this was my use case as well and the link were extremely helpful. Thank you.