[{"data":1,"prerenderedAt":35},["ShallowReactive",2],{"blog:post:en:proxy-timeout-vs-origin-timeout":3,"blog:related:en:proxy-timeout-vs-origin-timeout":22},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":14,"thumbnail_url":15,"translations":16,"body":17,"asset_base":18,"checksum":19,"published_at":20,"content_updated_at":21},"proxy-timeout-vs-origin-timeout","en","Proxy Timeout vs Origin Timeout: How to Tell the Difference","Learn to distinguish proxy timeouts from origin server timeouts, set separate timeouts in Python and Node.js, and retry only when it helps.","2026-11-20",[10,11,12,13],"proxy","python","proxy-rotation","troubleshooting",[10,11,12,13],"https://blog-api.ro-proxy.com/api/blog/posts/proxy-timeout-vs-origin-timeout/thumbnail.svg?lang=en",[5],"## Why Proxy Timeouts Are Easy to Misdiagnose\n\nWhen a request through a proxy hangs, the natural instinct is to blame the target website. That is often wrong. A proxy is an extra network hop between your client and the origin. The failure can happen before the request ever reaches the origin, or after the origin has already responded and the proxy is sending the answer back.\n\nTreating every timeout as an origin problem leads to two mistakes: you retry against a broken proxy, wasting rotation credits and time, or you rotate IP addresses when the origin server is simply slow. Both make your scraper less reliable and harder to debug.\n\n## Where a Proxy Request Can Fail\n\nA request routed through an HTTP proxy goes through these stages:\n\n1. Your computer resolves the proxy hostname and opens a TCP connection to the gateway port.\n2. For HTTPS, your client sends an HTTP CONNECT request through the proxy to establish a tunnel to the origin.\n3. The proxy forwards the TLS handshake to the origin.\n4. Your HTTP request travels through the tunnel.\n5. The origin processes the request and sends a response back through the proxy.\n\nA timeout can occur at any stage. If the proxy gateway is unreachable, the failure looks like a connection timeout. If the proxy resolves DNS slowly, the first byte may take a long time even though the origin is fine. If the origin is overloaded, the proxy waits for a response and your client sees a read timeout.\n\nThe key diagnostic question is: did the failure happen before or after the proxy forwarded the request to the origin?\n\n## Timeout Types to Configure\n\nSet timeouts separately for each layer:\n\n- **Connect timeout**: How long to wait for the TCP connection to the proxy gateway. If this fails, the origin was never contacted.\n- **Read timeout**: How long to wait for data once the connection is established. This covers proxy processing, origin processing, and network transfer.\n- **TLS handshake timeout**: How long to wait for the secure tunnel to the origin through the proxy.\n- **Total request timeout**: A hard ceiling for the entire operation.\n\nDo not use a single generic timeout for everything. A short connect timeout catches dead proxies quickly. A longer read timeout allows slow origins to finish without triggering unnecessary retries.\n\n### Configuring Your Proxy\n\nRoProxy proxies connect through a gateway host on an HTTP port, and the same URL works for both HTTP and HTTPS traffic. Use this form:\n\nhttp://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT\n\nPro and Business plans also provide a SOCKS5 port:\n\nsocks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT\n\nThe socks5h scheme tells the client to resolve DNS at the proxy rather than locally. Use it when the origin hostname resolves differently depending on geographic location, or when your local network blocks direct DNS lookups for the target domain.\n\n## Python Example: Identify the Failure Layer\n\nThis example uses the requests package. It configures the proxy, sets distinct timeouts, and catches exceptions so you can tell where the request broke.\n\n```python\nimport requests\nfrom requests.exceptions import (\n    ConnectTimeout,\n    ReadTimeout,\n    ProxyError,\n    RequestException,\n)\n\nPROXY_URL = 'http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT'\n\nproxies = {\n    'http': PROXY_URL,\n    'https': PROXY_URL,\n}\n\ntry:\n    response = requests.get(\n        'https://api.ipify.org?format=json',\n        proxies=proxies,\n        timeout=(5, 20),\n    )\n    response.raise_for_status()\n    print(response.json())\n\nexcept ConnectTimeout:\n    print('Proxy gateway connect timeout: the proxy itself is unreachable.')\nexcept ProxyError as exc:\n    print(f'Proxy error: {exc}')\nexcept ReadTimeout:\n    print('Read timeout: the proxy connected, but no data arrived in time.')\nexcept RequestException as exc:\n    print(f'Other request failure: {exc}')\n```\n\nIf you need remote DNS resolution, switch to the SOCKS5 URL:\n\n```python\nPROXY_URL = 'socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT'\n```\n\n## Node.js Example with Native HTTP\n\nNode.js does not pass proxy settings to fetch automatically. This example uses the built-in http and https modules with the https-proxy-agent package.\n\n```javascript\nconst https = require('https');\nconst HttpsProxyAgent = require('https-proxy-agent');\n\nconst proxyUrl = 'http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT';\n\nconst agent = new HttpsProxyAgent({\n  proxy: proxyUrl,\n  connectTimeout: 5000,\n});\n\nconst req = https.request(\n  {\n    hostname: 'api.ipify.org',\n    path: '/?format=json',\n    agent,\n    timeout: 20000,\n  },\n  (res) => {\n    let data = '';\n    res.on('data', (chunk) => (data += chunk));\n    res.on('end', () => console.log(data));\n  }\n);\n\nreq.on('timeout', () => {\n  req.destroy(new Error('Request timed out'));\n});\n\nreq.on('error', (err) => {\n  if (err.code === 'ECONNREFUSED') {\n    console.error('Proxy gateway refused the connection.');\n  } else if (err.code === 'ETIMEDOUT') {\n    console.error('Timed out waiting for proxy or origin.');\n  } else {\n    console.error(err.message);\n  }\n});\n\nreq.end();\n```\n\nThe connectTimeout option applies to reaching the proxy. The socket timeout applies to waiting for data. Separating them lets you distinguish a dead proxy from a slow origin.\n\n## cURL for Quick Diagnosis\n\nUse cURL with verbose output to see exactly where a request stops:\n\n```bash\ncurl -v \\\n  --proxy http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT \\\n  --connect-timeout 5 \\\n  --max-time 20 \\\n  https://api.ipify.org?format=json\n```\n\n--connect-timeout limits the time to reach the proxy. --max-time limits the entire operation. If the verbose output stops after CONNECT but before the HTTP response, the proxy connected but the origin or tunnel is slow. If it never reaches CONNECT, the proxy gateway is unreachable.\n\nTo compare, run the same request directly without --proxy. If the direct request succeeds and the proxied request fails, the problem is the proxy layer. If both fail similarly, the origin or your local network is the likely culprit.\n\n## Retry Only After You Know the Layer\n\nDo not rotate or retry blindly on every timeout.\n\n- Proxy connect failure: Retry with a backoff. If it keeps failing, the gateway or your credentials may be the issue, not the target website.\n- Proxy read timeout: First verify whether the origin responds directly. If the origin is slow, retrying through the same proxy may help if the proxy was temporarily overloaded. If the origin is fast directly but slow through the proxy, the proxy is the bottleneck.\n- Sticky versus timed rotation: A sticky proxy keeps its IP until it is rotated or fails. If a sticky proxy starts timing out, rotate it once and then retry. A timed proxy changes its IP after an interval you set; do not force extra rotations inside that interval unless you have evidence the current IP is failing.\n\nOn the Free plan, the IP changes on a fixed schedule and cannot be rotated by hand, so your retry logic should rely on backoff rather than on-demand rotation. On Pro and Business plans, you can rotate a proxy immediately when you confirm it is the failure point.\n\n## Real-World Scenario: A 504 After Ten Seconds\n\nImagine your scraper receives HTTP 504 after ten seconds through a proxy. You suspect the target API is down. Before rotating IPs, run this check:\n\n1. Request the same endpoint directly from your machine.\n2. If the direct request also takes ten seconds and returns 504, the origin is slow or overloaded. Retry with backoff, but do not rotate solely because of the error.\n3. If the direct request returns in one second, the proxy is adding latency or failing to forward. Rotate the proxy and retry.\n\nThis distinction prevents you from burning through proxy IPs for an origin problem you cannot fix by changing addresses.\n\n## Conclusion\n\nTimeouts are not all the same. A connect timeout usually means the proxy gateway is unreachable. A read timeout can mean the proxy, the tunnel, or the origin is slow. By setting separate timeouts, checking verbose cURL output, and comparing direct versus proxied requests, you can fix the right layer instead of guessing.\n\nConfigure your gateway with http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT for HTTP and HTTPS traffic, or use socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT when you need remote DNS resolution. RoProxy gives each proxy its own username and password, and Pro and Business plans include a SOCKS5 port plus on-demand rotation through the API. Use those controls to rotate only when the proxy is truly at fault, and keep your scrapers reliable without unnecessary IP changes.\n","https://blog-api.ro-proxy.com/api/blog/posts/proxy-timeout-vs-origin-timeout/assets","818e49fa8af72fc6b58d0c46b599f4666d69492630fac6b8479f5dec8449bd57","2026-11-20T01:03:32.404309Z","2026-11-20T01:03:32.406349Z",[23,27,31],{"slug":24,"title":25,"summary":26},"lightweight-proxy-health-checks-python-stdlib","Lightweight Proxy Health Checks with Python Stdlib","Build a dependency‑free Python script that tests proxy connectivity, measures latency, and verifies IP rotation using only the standard library.",{"slug":28,"title":29,"summary":30},"verify-proxy-exit-ip-routing","Verify Proxy Exit IP and Protocol Routing","Confirm your proxy is routing traffic and hiding your real IP by checking the exit address over HTTP and HTTPS with cURL and Python.",{"slug":32,"title":33,"summary":34},"socks5-remote-dns-vs-local-dns-test","SOCKS5 Remote DNS vs Local DNS: A Practical Test","Learn how SOCKS5 local and remote DNS change proxy behavior, then test both with curl and Python to avoid leaks and failed resolutions.",1796251609529]