Sunday, 5 March 2017

Solving `Empty reply from server` in DotNet Core


If you’re getting curl: (52) Empty reply from server check that you’ve configured Kestrel correctly.

Long version

I’ve started playing with Dotnet Core and Docker and have had a few issues getting started. I’ve had a little bit of experience with Docker, though only a little. I’ve worked with DotNet previously but never with Core.


The setup I’m using is a Windows laptop running Vagrant. Via Vagrant I’m running an Ubuntu Virtual Machine with the Docker run time installed. Feels a litle like inception.

Key Problem

The key problem that I’ve had getting started was having my Docker container not responding correctly to my curl commands. I get this:
curl: (56) Recv failure: Connection reset by peer
curl: (52) Empty reply from server
Given that I’m not all that familliar with Docker or Dotnet Core I decided to remove one of the variables and set up a simple Express app in a different docker container. This validated that the commmand I was using to run the container (docker run -v /vagrant/dotnetcoretest/src:/src -p 5000: 5000 -d dnctest dotnet run) was binding the ports correctly.
This left a problem with the Dotnet Core web api app. I was surprised that this would be the problem given that I had created the app with the dotnet new webapigenerator.
Searching around I found that the problem was that by default Kestrel listens on localhost:5000. To fix this add .UseUrls("http://*:5000") to the WebHostBuilder in Program.cs. It should now look like
public class Program
    public static void Main(string[] args)
        var host = new WebHostBuilder()

Rebuild the app and run curl localhost:5000/api/values and you should get ["value1","value2"].


  1. Hi, am a big follower of your blog.All the details are explained in detail manner.keep it up.Thanks for sharing.... Dot Net Training in Chennai
    Hadoop Training in Chennai

  2. Hi, I am really happy to found such a helpful and fascinating post that is written in well understandable manner enhance me to learn quickly… Thanks..
    Web Designing Training in Chennai | Big Data Analytics Training in Chennai

  3. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    dot-net training in chennai

  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.