How to allow curl via a local proxy? - linux

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?

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

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.

Related

Logs to troubleshoot SSH tunneling errors

I am trying to troubleshoot connection errors when using SSH tunneling to connect to a rhel 8 EC2 server. Does anyone know of a log location on RHEL 8 that may contain more information when the connection is refused?
For reference I am using the following command (which works on all my other servers)
ssh -i -L 8745:IPOfServer:8443 ec2-user#IPOfServer
I get the error "open failed: connect failded: Connection refused
I can connect on 8080 but 8443 is refused even though the port is open and the application and firewalld are configured to listen on 8443 and 8080.
Thanks!!

cURL error 7: Failed to connect to 127.0.0.1 port 8888: Connection refused (nginx)

I got 3 curl calls in my laravel code
$fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('http://127.0.0.1:8090');
$solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('http://127.0.0.1:8091');
$client = new \EOSPHP\EOSClient('http://127.0.0.1:8888');
$fullNode and $solidityNode work without any problem.
$client gets the following error message:
cURL error 7: Failed to connect to 127.0.0.1 port 8888: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
I checked this on my nginx machine:
sudo netstat -tulpn | grep LISTEN
The result did show 8090 and 8091 but not 8888.
I guess there is a problem with the port, it might not open? I'm not that experienced in working with ports, may someone can tell me where to go from here and if/ where i open the port for LISTEN to CURL? As said, this is a nginx linux machine.

Why can't I curl to 127.0.0.1 localhost, but I can to the instance.localhost?

When I connect to my server on localhost via web browser, it works, but when I curl to localhost, it does not work. I have to nslookup instance.localhost to find where my server is.
Why is instance.localhost not 127.0.0.1? How do I prevent my server from changing from 127.0.0.1?

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.
Make sure you have a service started and listening on the port.
netstat -ln | grep 8080
and
sudo netstat -tulpn
Try curl -v http://localhost:8080/ 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 http://localhost:8080/
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.

Vagrant Port Forwarding not working

I've installed CouchDB on my vagrant 0.9.0 box that is running CentOS 6.2.
In Vagrantfile I've added config.vm.forward_port 5984, 5985.
After reloading vagrant i attempt to curl the address: curl -v localhost:5985 with poor results.
* About to connect() to localhost port 5985 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5985 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host: localhost:5985
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection #0
I get the feeling that port forwarding isn't working properly - at first I thought it might have something to do with iptables so I disabled that but, alas, results did not improve.
Been beating my head against this for days now. Would greatly appreciate some assistance.
It's quite likely that your CouchDB is listening on address 127.0.0.1 of the virtual machine (not of the physical machine). This is the default for CouchDB. Do you have the following in local.ini?
[httpd]
bind_address = 0.0.0.0
After restarting CouchDB check with netstat, on the virtual machine, if the change took effect:
sudo netstat -tlnp |grep :5984
Then check that CouchDB is running fine from the virtual machine:
curl http://127.0.0.1:5984/
If you don't see {"couchdb":"Welcome","version":"1.1.1"}, check the logs for error messages. It may be some permissions problem.
How have you installed CouchDB?
in my case, the solution to a very similar problem was much more obvious: coming from ubuntu, I didn't expect a firewall to be running on the centos box
this will disable it:
sudo service iptables stop
thanks to this blog!

Resources