Curl : connection refused
Mia Lopez
I got the following error while running curl:
curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused.
It seems that it is easy to debug, but, I didnt find how to solve it.
The adress 127.0.0.1 is mentioned in the file etc/hosts.
I am using curl version 7.47 on Ubuntu system.
Anyone has an idea about it ?
Thank you.
85 Answers
Make sure you have a service started and listening on the port.
netstat -ln | grep 8080and
sudo netstat -tulpn Try curl -v instead of 127.0.0.1
Listen to the port in one session and then open another session to test it with l$ curl -v
It should work. That's how I worked although in l Termux
You have to start the server first, before using curl. On 8/10 occasions that error message arises from not starting the server initially.
127.0.0.1 restricts access on every interface on port 8000 except development computer. change it to 0.0.0.0:8000 this will allow connection from curl.
2