Can't connect to any service through localhost (drone 0.7.0)


I followed the simplest drone manifest with one service:

    image: golang
      - curl http://localhost:27017

    image: mongo:latest

In the logs I see: curl: (7) Failed to connect to localhost port 27017: Connection refused

  • I see in the logs of ‘drone exec --local’ that the mongo service starts. (also tried with sleep)
  • Not sure if it’s still relevant but I have socat installed as well

Any clue ? further debugging hints?


This is the expected behavior. The docker containers (the container in your pipeline and the mongo container) are on different networks with different IP addresses, and therefore cannot communicate via localhost. Instead you need to use the container hostname.

You can see examples and read more about it here:

Hey bradry appreciate the work on drone.
But could we put some work into cleaning up the docs.

Spent fair to long believing that they were both on local host due to this Having no idea it was out of date!
I didn’t even know was a thing! @bradrydzewski

I do plan to clean up the documentation but have not had the free time or financial resources to fund such an effort. It will get done eventually, but it will take time.