Curl: Connection Refused

Curl: Connection Refused

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.

8

5 Answers

Make sure you have a service started and listening on the port.

netstat -ln | grep 8080

and

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.