Proxy keeps disconnecting? Why 4G proxies drop connections and how to handle it
In this article
- 01 Why does my proxy keep disconnecting?
- 02 Find the pattern with a test loop
- 03 Rotation cuts open connections
- 04 IPv6 addresses fail straight away
- 05 Idle and reused connections
- 06 Short drops on the 4G line
- 07 Retry code that survives drops
- 08 When to contact support
- 09 65Proxy's Singapore 4G proxies
- 10 Frequently asked questions
A proxy that works and then suddenly drops connections usually has one of four causes: a rotation cutting open connections, an IPv6 address the 4G line can't reach, an idle connection that was closed while your tool still held it, or a short drop on the 4G line itself. A five-second test loop tells you which one it is, and a few lines of retry code make your script survive all four.
Why does my proxy keep disconnecting?
Match what you see to the likely cause, then jump to its section:
| What you see | Likely cause | Fix |
|---|---|---|
| Requests fail for a few seconds, then work with a new IP | Rotation | Don't rotate while requests are running |
| One site always fails at once, others work | IPv6 address | Use socks5h:// or force IPv4 |
| The first request after a pause fails, the next one works | Idle connection | Retry once on connection errors |
| Everything fails or crawls for a few minutes, then recovers | Line drop | Retry with backoff, then contact support |
| Always fails, from the very first request | Wrong details or expired plan | See common proxy errors |
A 4G proxy is a real modem with a SIM card on a mobile network, so it will never be as steady as a server in a data center. That's the price of a carrier IP that sites treat like a phone. The good news is that every one of these drops is short and can be handled in code.
Find the pattern with a test loop
Before changing anything, record what the proxy does over a few minutes. This loop requests a small page every 5 seconds and prints the time (UTC), curl's exit code, the HTTP status and how long it took:
export PROXY="http://USER:PASS@HOST:PORT"
while true; do
out=$(curl -s -o /dev/null -x "$PROXY" -m 20 -w '%{http_code} %{time_total}s' https://api.ipify.org)
code=$?
echo "$(date -u +%H:%M:%S) exit=$code $out"
sleep 5
doneOn Windows, the same loop in PowerShell:
$env:PROXY = "http://USER:PASS@HOST:PORT"
while ($true) {
$out = curl.exe -s -o NUL -x $env:PROXY -m 20 -w "%{http_code} %{time_total}s" https://api.ipify.org
"{0} exit={1} {2}" -f (Get-Date).ToUniversalTime().ToString("HH:mm:ss"), $LASTEXITCODE, $out
Start-Sleep 5
}Let it run for 5 to 10 minutes, then read the exit codes:
exit=0with200: the proxy works. If your tool still fails at that moment, the problem is in the tool's settings.exit=7: no connection. Run the command once with-vto see which side failed:Failed to connectmeans curl couldn't reach the proxy, whileCONNECT tunnel failed, response 502means the proxy couldn't reach the site (older curl versions report that one as exit 56).exit=28: the request timed out after 20 seconds.exit=97: the SOCKS5 connection failed when you test a SOCKS5 port, for examplecannot complete SOCKS5 connection(older curl versions writeCan't complete).
A few failures in a row followed by normal results points to a rotation or a line drop. Failures on one site only point to IPv6. Times that keep growing point to too much traffic on one line, covered in proxy speed.
Rotation cuts open connections
Rotating a 4G proxy makes the modem disconnect from the network and connect again to get a new IP. That takes a few seconds, and every connection open at that moment is cut: a page halfway through loading, a file download, a WebSocket.
- Rotate only when nothing is running. Finish or pause the current requests, rotate, wait for the new IP, then continue.
- Remember the parallel workers. Every worker on the same proxy shares the IP, so a rotation started by one of them cuts all the others.
- Wait for the new IP before sending work. The full "call the link, then poll until the IP changes" code is in rotating the IP with an API.
Each 65Proxy proxy rotates at most once every 5 minutes, so a script that rotates more often gets a refusal, not a new IP.
IPv6 addresses fail straight away
The 4G lines behind 65Proxy carry IPv4 only. When your tool hands the proxy an IPv6 address, the proxy can't reach it and answers in a fraction of a second:
- SOCKS5: "general failure" (reply 1), which curl shows as
cannot complete SOCKS5 connection to example.com. (1). - HTTP:
502 Bad Gatewayon theCONNECTrequest.
This happens most with socks5://, where your own machine looks up the site's name and may pick its IPv6 address (many sites, example.com among them, have one). The fixes:
- Use
socks5h://so the proxy looks up the name itself and gets an address it can reach. The difference is explained in socks5 or socks5h. - Force IPv4 in curl with
-4. - Give tools a site name, never a raw IPv6 address.
If a site has only an IPv6 address, an IPv4 proxy can't open it at all. More on the two versions in IPv4 vs IPv6 proxies.
Idle and reused connections
Most HTTP libraries keep connections open and reuse them to save time. On mobile networks, a connection that sits idle can be closed along the way without your program noticing. The next request on it then fails with errors like:
- Python:
ConnectionResetError,RemoteDisconnectedorConnection aborted. - Node.js:
ECONNRESETorsocket hang up. - Browsers:
ERR_CONNECTION_RESETon the first click after a pause.
The fix is simple: retry once on a connection error, which opens a fresh connection (code in the retry section). For long-lived connections such as WebSockets, send a small ping every 20 to 30 seconds and reconnect automatically when the socket closes.
Short drops on the 4G line
Now and then a 4G line drops for a few minutes, for example when the modem loses signal or restarts. In the test loop it looks like this:
- Several minutes of failures in a row:
exit=7(can't connect) andexit=28(timeouts). - Slow replies of several seconds on the requests that do get through.
- Recovery on its own, back to normal times.
These drops belong to the line, not to your settings, and changing your setup during one won't help. What does help:
- Retry with growing pauses (backoff), as in the code below, instead of hammering the proxy.
- Pause the job when retries keep failing for more than a few minutes, rather than marking every task as failed.
- Save progress as you go, so a drop costs you a few minutes and not a whole run.
- Spread important jobs over two or more proxies, so one line dropping doesn't stop everything. How many you need is in how many proxies do you need.
Retry code that survives drops
This Python example (requests) retries connection errors, timeouts and 502/503/504 answers, waiting 5, 10, 20 and 40 seconds between tries. It covers idle connections, rotations and short line drops, and gives up with a clear message when the line stays down:
import os
import time
import requests
PROXY = os.environ["PROXY"] # http://USER:PASS@HOST:PORT
session = requests.Session()
session.proxies = {"http": PROXY, "https": PROXY}
def get(url, tries=5):
for attempt in range(1, tries + 1):
try:
resp = session.get(url, timeout=(10, 30))
if resp.status_code not in (502, 503, 504):
return resp
print("attempt", attempt, "got", resp.status_code)
except (requests.ConnectionError, requests.Timeout) as err:
print("attempt", attempt, "failed:", type(err).__name__)
if attempt < tries:
time.sleep(5 * 2 ** (attempt - 1))
raise RuntimeError("The proxy is still failing; check the line or contact support")
print(get("https://api.ipify.org").text)A few rules that apply in any language:
- Always set a timeout. Without one, a single request can hang forever and stall the whole script.
- Don't retry IPv6 failures. A 502 that comes back instantly on every try is the IPv6 case, not a drop.
- Don't retry
407. It means the username or password is wrong, and retrying won't change that; see 407 errors. - Log the time of each failure in UTC. It's what support needs to look at the line.
More Python setups (httpx, aiohttp, SOCKS5) are in using a proxy in Python.
When to contact support
Contact support when the test loop shows failures for more than about 10 minutes, or short drops many times a day. Send:
- The proxy's host and port (not the password).
- The times of the failures in UTC, copied from the test loop.
- The exact error, from curl
-vor your tool. - What you tested: the HTTP or SOCKS5 port, and which site.
With that, we can look at the line at those moments, restart the modem or move your proxy to another modem when one is free.
65Proxy's Singapore 4G proxies
65Proxy proxies run on Singtel and M1 4G modems in Singapore. Each proxy has an HTTP port and a SOCKS5 port with one username and password, plus a rotation link (at most once every 5 minutes), and is not shared with other customers.
- Plans: 1 day $4, 7 days $13, 1 month $32, plus monthly plans with more bandwidth (500GB $40, 1TB $65).
- Try it first: run the test loop above on the free 1-hour trial before you pay.
- Buy: get a Singapore 4G proxy; it is delivered automatically once paid.
- Support: the live chat on the site, with the times and errors from your test loop.
Frequently asked questions
Is it normal for a 4G proxy to drop sometimes?
Short drops of a few seconds to a few minutes are normal on any mobile line. Long outages, or failures every few minutes all day, are not: run the test loop and contact support.
Will more threads make it more stable?
No, usually the opposite. Every thread shares one 4G line, so too many parallel requests make replies slower and timeouts more frequent. Use fewer threads per proxy, or several proxies.
Why does curl work but my browser keeps failing?
The browser may be using the SOCKS5 port, which Chrome and Edge can't use with a password, or keeping old connections from before a rotation. Use the HTTP port in Chrome, as explained in setting up a proxy in Chrome, and restart the browser after rotating.
Does a VPN on my computer cause drops?
It can. A VPN changes how your computer reaches the proxy, and some VPNs or antivirus programs block unusual ports. Turn it off and run the test loop again to compare.