Curl (7): Failed to Connect to Localhost Port 8000: Connection Refused

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

if you are using linux, make sure the server is running using

/etc/init.d/httpd status

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

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>

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

Are you trying to connect inside the container?

If not, you may fight this other unrelated question (covering the outside container case) helpful:

From inside of a Docker container, how do I connect to the localhost of the machine?

curl Failed to connect to localhost port 80

Since you have a ::1 localhost line in your hosts file, it would seem that curl is attempting to use IPv6 to contact your local web server.

Since the web server is not listening on IPv6, the connection fails.

You could try to use the --ipv4 option to curl, which should force an IPv4 connection when both are available.



Related Topics



Leave a reply



Submit