DEV Community

RoamProxy
RoamProxy

Posted on

Proxy won't connect? Tell a blocked port from a bad password in 30 seconds

"The proxy doesn't work" usually means one of three different things, and each one needs a different fix:

  1. Your network never reaches the proxy. Something between you and the proxy drops the traffic, usually a firewall that only allows a short list of outbound ports.
  2. You reach the proxy host, but nothing is listening on that port. Usually a typo in the host or port.
  3. You reach the proxy and it rejects you. Wrong username or password, or the wrong protocol.

You can tell them apart with one curl command, because each case fails in its own way.

The one command

curl -v --connect-timeout 5 -x http://PROXY_HOST:PORT https://example.com -o /dev/null
Enter fullscreen mode Exit fullscreen mode

Leave the credentials out on purpose for the first run. You are not trying to load the page yet, you are only checking what kind of answer the proxy port gives you.

Reading the result

Case 1: timeout. The port is filtered on your network.

*   Trying 172.93.220.235:9999...
curl: (28) Failed to connect to gw.roamproxy.com port 9999 after 5003 ms: Timeout was reached
Enter fullscreen mode Exit fullscreen mode

Nothing came back at all. A firewall silently dropped the packets. This is what an office network, a hotel Wi-Fi or a strict cloud security group usually does to ports it does not allow. Typing the password again will not help, because the request never reached the proxy.

Case 2: connection refused. The host was reached, but nothing listens there.

curl: (7) Failed to connect to 127.0.0.1 port 9 after 0 ms: Couldn't connect to server
Enter fullscreen mode Exit fullscreen mode

You got an immediate "no" instead of silence. Check the hostname and port against your provider's dashboard. A refused connection can also come from a local firewall that rejects connections instead of dropping them, so if the values are right, try the next case's test from another network.

Case 3: 407. You reached the proxy. Now fix the credentials.

* Connected to gw.roamproxy.com (172.93.220.235) port 8080
> CONNECT example.com:443 HTTP/1.1
< HTTP/1.1 407 Proxy Authentication Required
curl: (56) CONNECT tunnel failed, response 407
Enter fullscreen mode Exit fullscreen mode

This is the good failure. The network path works, and the proxy is asking who you are. Add -U 'user:password' (with single quotes, so characters like # or ! reach curl unchanged) and run it again. If it still says 407, the credentials are wrong or belong to a different product.

If the port is filtered

You have three options:

  • Use an alternative port, if your provider offers one. Many proxy services listen on more than one port for exactly this reason. Ports like 8080 are often allowed on networks that block uncommon high ports.
  • Test from a different network. A phone hotspot is the quickest way. If the same command gets a 407 there, the problem is your local network, not the proxy.
  • Ask your network admin to allow the port to the proxy host only. That is a small request compared with opening all outbound traffic.

A quick check without curl

If you only want to know whether the port is reachable:

nc -vz -w 5 PROXY_HOST PORT
Enter fullscreen mode Exit fullscreen mode

"succeeded" or "open" means the TCP path works. A timeout means the port is filtered, the same as Case 1.

How this applies to Roam

Our gateway gw.roamproxy.com listens on port 41080 and, since this week, also on port 8080. Both ports are the same gateway: same username, password, HTTP/SOCKS5 support, geo-targeting and sticky sessions. If the Case 1 test times out on 41080, run it again on 8080 before you change anything else.

curl -v --connect-timeout 5 -x http://gw.roamproxy.com:8080 https://example.com -o /dev/null
Enter fullscreen mode Exit fullscreen mode

A 407 there means you are through. Add your gateway credentials and you are done.

Takeaway

Before you change passwords or open a support ticket, run one curl -v and see how it fails. A timeout means the network blocks the port, a refusal means the host or port is wrong, and a 407 means you reached the proxy and only the credentials need fixing.

Written by the team at Roam (roamproxy.com). We run a residential and static proxy gateway and use these checks when users write in.

Top comments (0)