Docker nancy – no route to host

I have a docker container which hosts a web api written in Nancy. Here is the exception that occurs after a web request is made when the container is first fired up:

    4/22/2016 2:40:50 PM  at API.SearchModule+<SearchModule>c__AnonStorey0.<>m__0 (System.Object _) <0x41380aa0 + 0x00850> in <filename unknown>:0 
    4/22/2016 2:40:50 PM  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,System.Func`2<object, object>,object)
    4/22/2016 2:40:50 PM  at Nancy.Routing.Route+<>c__DisplayClass4.<Wrap>b__3 (System.Object parameters, CancellationToken context) <0x4133d350 + 0x00166> in <filename unknown>:0 
    4/22/2016 2:40:50 PM2016-04-22 13:40:50,177 ERROR: System.Net.WebException: Error: ConnectFailure (No route to host) ---> System.Net.Sockets.SocketException: No route to host
    4/22/2016 2:40:50 PM  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) <0x41374320 + 0x001b8> in <filename unknown>:0 
    4/22/2016 2:40:50 PM  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) <0x41372b50 + 0x00609> in <filename unknown>:0 

The app queries elasticsearch when a web request is made, initially I thought it was blowing up because it couldn’t find elastic (another docker container), however this doesn’t seem to be the case as locally if I stop elastic the api will continue serving requests albeit it will throw exceptions. Once elastic is back online, the api continues to serve requests this time without exceptions.

  • Why not “docker push” only publish the Dockerfile?
  • docker compose: rebuild of one linked container breaks nginx's upstream
  • How to find the CMD command of a docker image?
  • Is there an easy way to change to a non-root user in Bitbucket Pipelines Docker container?
  • Docker: Unable to connect to container from host
  • Does the disk property size you define in Marathon include the size of the docker image?
  • The bizarre thing is if the docker container is restarted again the web requests against the api are successful at querying elastic.

    Is there anyway I can replicate this issue locally so I can attempt to work on a fix? I had thought that if I run it locally with elastic offline I would get the same error, however this doesn’t seem to be the case which makes me think it’s some sort of network connectivity issue.

    What do you guys think it could be?

  • Configure appveyor for Docker
  • PHPUnit Selenium tests fail on Docker localhost and pass using public IP
  • No access to AWS RDS from AWS ECS Docker Container
  • How can I create predictive mappings between network interface names and bridged networks in docker
  • Cannot access server in docker container
  • How to figure out, what slows down docker?
  • One Solution collect form web for “Docker nancy – no route to host”

    It is a DNS problem. Your docker container is unable to resolve the IP address for the provided URL (Host).

    Take a look to the --dns option ( or amend the resolv.conf file inside your docker image/container.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.