Docker Community Forums

Share and learn in the Docker community.

Curl: (7) Failed to connect to localhost port 49160: Connection refused


(Mlotfi) #1

Hi,
I am still in this tutorial
https://docs.docker.com/engine/examples/nodejs_web_app/

in Test

$ curl -i localhost:49160

I got

alotfi@ITD-968735 ~/DockerTests/nodejsDockerImage
$ docker ps
CONTAINER ID        IMAGE                      COMMAND                CREATED             STATUS              PORTS
         NAMES
13e217434669        mlotfi/centos-node-hello   "node /src/index.js"   26 minutes ago      Up 26 minutes       0.0.0.0:49160->8080/tcp   sad_payne

alotfi@ITD-968735 ~/DockerTests/nodejsDockerImage
$ curl -i localhost:49160
curl: (7) Failed to connect to localhost port 49160: Connection refused

(Nathan Le Claire) #2

Are you on Linux? localhost is the localhost of the Linux system where Docker is being run.

If you’re using Docker Machine on Mac or Windows, you’ll need to curl docker-machine ip instead.

$ docker-machine ip default
192.168.99.1

$ curl 192.168.99.1:49160

EDIT: On older versions of DM you need to specify default explicitly in the ip command.


(Mlotfi) #3

I did

$ docker-machine ip
Error: Expected to get one or more machine names as arguments


(Nathan Le Claire) #4

You have a slightly older version of DM (you can get the latest through the Toolbox): the command you need is docker-machine ip default.


(Jonmach) #5

Yep - that got me too. It’s probably worth updating the post to put that info before the curl. I got stuck at that point, and didn’t read forward. If it was mentioned earlier, it would have gone without a hitch.


(Pete Sekan) #6

Hi! I run into exactly the same error but the suggested doesn’t work out for me. May you could provide any other hit or solution or even a reference where I can take a look.

I am working on the latest OS X and try to deploy a node.js/react.js app.

Any help is welcome, thanks!