Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: curl: (7) Failed to connect to localhost port 9089: Connection refused

Tags:

I am trying to connect to my IAM server by using:

curl -i -X POST -H "Content-type: application/json" http://localhost:9089/account/list -d '{"jwt": "jwt_token..."}'

and in doing so I get an error as follows:

curl: (7) Failed to connect to localhost port 9089: Connection refused

Any suggestions would be greatly appreciated!

Edit:

 > npm info it worked if it ends with ok npm info using [email protected] npm
    > info using [email protected] npm info lifecycle [email protected]~prestart:
    > [email protected] npm info lifecycle [email protected]~start: [email protected]
    > 
    > > [email protected] start /usr/src/app
    > > node server.js
    > 
    > HTTP listening on port 9089 HTTPS listening on port 9449

root@Ubuntu1604-001:/home/src/IAM# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
blandry/2           latest              f127789f2de7        4 days ago          544MB
blandry/3           latest              f127789f2de7        4 days ago          544MB

root@Ubuntu1604-001:/home/src/IAM# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                     NAMES
cc28d00d1667        blandry             "npm start"         33 minutes ago      Up 33 minutes       0.0.0.0:32768->9089/tcp   objective_mclean

Dockerfile:

FROM node:8.5.0-wheezy
RUN apt-get update

WORKDIR /usr/src/app
ENV ldap_port 389
ENV http_port 9089

ENV ladp_ip 10.119.226.149
ENV URL  10.119.226.149
ENV authentication eyJhbGciOiJIUz...

COPY package.json package-lock.json /usr/src/app/
COPY . .

EXPOSE 9089
CMD ["npm", "start"]
like image 962
ComputerGuy123 Avatar asked Sep 26 '17 19:09

ComputerGuy123


1 Answers

Try below

curl -i -X POST -H "Content-type: application/json" http://localhost: 32768/account/list -d '{"jwt": "jwt_token..."}'

Your docker ps shows

root@Ubuntu1604-001:/home/src/IAM# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                     NAMES
cc28d00d1667        blandry             "npm start"         33 minutes ago      Up 33 minutes       0.0.0.0:32768->9089/tcp   objective_mclean

That means you didn't map 9089 to 9089. To do that make sure you run your container as

docker run -p 9089:9089 <image>
like image 149
Tarun Lalwani Avatar answered Oct 01 '22 02:10

Tarun Lalwani