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.

  • Docker cp Path not specified
  • Docker error trying login (and anything)
  • Elasticsearch 5.1 and Docker - How to get networking configured properly to reach Elasticsearch from the host
  • docker swarm in aws is unreachable after reboot
  • Configure fig to run one container before another
  • Makefile - append to command
  • 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?

  • Identifying files contained within a docker image (or Application dependencies)
  • Not able to access Flask Web application running inside a Docker container
  • How to build Docker Image with Fake
  • docker-py: Accessing output of python script run in ENTRYPOINT command
  • Cannot install plugin for IBM Container on Cloud Foundry on mac OS
  • Some questions from a newbie on Docker and Docker Elasticsearch image
  • 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.