Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow curl via a local proxy?

According the the Charles Proxy configuration page, you can manually set up a proxy if you use your localhost with port 8080.

The syntax is curl --proxy localhost:8080 http://google.com/

However, this is not working for me. Here is my syntax and results - i'm also using the -v option for debugging:

curl -v --proxy localhost:8080 http://google.com/

* About to connect() to proxy localhost port 8080 (#0)
*   Trying 127.0.0.1... Connection refused
*   Trying ::1... Connection refused
*   Trying fe80::1... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

I can connect to localhost:8080 in the web browser, and the results are logged in the proxy. However this is not working, the connecting is refused and nothing is logged.

So far I have also tried:

- executing this as root
- using 127.0.0.1 instead of localhost
- using wget instead of curl
- disabling the system firewall

What am I doing wrong? What else can I try?

like image 856
cwd Avatar asked Sep 19 '11 16:09

cwd


2 Answers

I had some success using port 8888: curl http://www.google.com --proxy 127.0.0.1:8888

like image 124
rrrhys Avatar answered Sep 21 '22 07:09

rrrhys


Connection refused would suggest that nothing is listening on port 8080. Charles has to be running (and listening on port 8080) for curl to be able to use it as a proxy. That or you've got a firewall actively blocking that port, preventing anything from connecting.

like image 26
Marc B Avatar answered Sep 22 '22 07:09

Marc B