---
title: "How to Read Proxy Logs: Debugging With curl and Python"
description: "When a proxy request fails, read the verbose output first: curl -v and Python logging show if it stopped at DNS, TCP, CONNECT, TLS or the target site."
url: https://proxynet.io/blog/reading-proxy-logs
date: 2026-12-01
author: "Acar Diveroli"
category: "Tutorial"
lang: en
---

# How to Read Proxy Logs: Debugging With curl and Python

A proxy log is the verbose output a client writes while it connects through a proxy. In curl `-v` turns this output on, and in Python debug logging does. The cause of an error usually sits in the lines before the last one. The log shows at which stage the request stopped: the connection to the proxy, the tunnel request, encryption or the target site's response. This post explains the lines in the log, four failure scenarios and how to make the same diagnosis in Python.

> **Note: Short answer**
>
> Run the request with `curl -v`, or in Python with `http.client` debugging plus urllib3 logging, then find the last `<` line. If no tunnel response (`200`, `407`, `403`) arrived, the problem is on the way to the proxy. If it did, look at TLS or the target site.

## Turning on verbose output

In curl, `-v` turns on verbose output. Lines start with one of three markers: `*` is curl's own note, `>` is a header sent, `<` is a header received. `--trace-time` adds a timestamp to every line. With it you can measure the gap between stages.

```bash
curl -v --trace-time -o /dev/null \
  -x http://user:pass@pr.proxynet.io:8000 \
  https://example.com 2> curl-log.txt
```

Verbose output goes to stderr, and `2>` writes it to a file. On Windows, write `NUL` instead of `/dev/null`. In PowerShell 5.1 the `curl` alias points to a different command, so type `curl.exe`. The `-x` setup is covered in detail in [cURL with Proxy: How to Set HTTP and SOCKS5 Proxies](/blog/curl-proxy).

## Lines of a successful request

A successful HTTPS request through a proxy passes five stages: DNS, TCP, `CONNECT`, TLS and the target's response. The output below came from our local test proxy, which is why the address shows as `127.0.0.1`. We shortened it.

```text
*   Trying 127.0.0.1:8000...
* Proxy auth using Basic with user 'user'
* Establishing HTTP proxy tunnel to example.com:443
> CONNECT example.com:443 HTTP/1.1
> Host: example.com:443
> Proxy-Authorization: Basic dXNlcjpwYXNz
> User-Agent: curl/8.22.0
>
< HTTP/1.1 200 Connection established
* CONNECT tunnel established, response 200
* ALPN: curl offers http/1.1
* ALPN: server accepted http/1.1
> GET / HTTP/1.1
> Host: example.com
* Request completely sent off
< HTTP/1.1 200 OK
```

1. **DNS.** If the proxy address is a domain name, curl resolves it first. The client does not resolve the target's name. It passes the name to the proxy in the `CONNECT` line.
2. **TCP.** The `Trying` line is the connection attempt to the proxy. Without an error, the next line follows.
3. **CONNECT.** curl asks the proxy for a tunnel to `example.com:443`. `< HTTP/1.1 200 Connection established` says the tunnel is open.
4. **TLS.** Encryption is set up through the tunnel, directly with the target. The ALPN lines show that the handshake has finished.
5. **The target's response.** The `< HTTP/1.1 200 OK` after the `GET` request comes from the site, not from the proxy.

The trap is in stage 3. The `dXNlcjpwYXNz` in the `Proxy-Authorization` line is not encrypted. Decode the base64 and you get `user:pass`. The curl that ships with Windows uses Schannel for TLS and sums up the handshake in a few lines. Builds on other systems write this stage out in more detail. How the tunnel works is explained on the [HTTPS Proxy](https://proxynet.io/https-proxy) page.

## Four failure scenarios

In a failed request, the last `<` line tells you which stage the request got through. We ran the same command with four broken settings.

**Wrong password.** The tunnel request goes out, and the proxy turns it down with 407:

```text
> CONNECT example.com:443 HTTP/1.1
> Proxy-Authorization: Basic dXNlcjp3cm9uZw==
< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: Basic realm="test"
* CONNECT tunnel failed, response 407
curl: (7) CONNECT tunnel failed, response 407
```

**Closed port.** There is no `>` line at all. The TCP connection never came up:

```text
*   Trying 127.0.0.1:8001...
* connect to 127.0.0.1 port 8001 from 0.0.0.0 port 56745 failed: Connection refused
curl: (7) Failed to connect to example.com:443 over proxy 127.0.0.1 after 0 ms: Could not connect to server
```

**Timeout.** We used a port that accepts the connection and never answers. The `CONNECT` goes out, and no `<` line ever comes back:

```text
> CONNECT example.com:443 HTTP/1.1
> Proxy-Connection: Keep-Alive
>
* Connection timed out after 5007 milliseconds
curl: (28) Connection timed out after 5008 milliseconds
```

**Unresolvable proxy name.** The request ends at the DNS stage: `curl: (5) Could not resolve proxy: pr.proxynet.invalid`.

In our test, both the 407 and the closed port ended with exit code `7`. So checking only the exit code in a script is not enough. The words `response 407` and `Connection refused` tell them apart.

## Log signal and stage

Every error line maps to a stage, and the stage tells you where to look. We produced every row of the table in our test. What the codes mean is covered in [Proxy Error Codes: What 407, 502, 503 and 504 Mean](/blog/proxy-error-codes).

| Signal in the log | Stage | Likely cause |
|---|---|---|
| `Could not resolve proxy` | DNS | Proxy address mistyped or DNS not working |
| `Connection refused` | TCP | Wrong port or nothing listening at that address |
| `CONNECT` sent, no `<`, `(28)` | CONNECT | Proxy or the network in between not answering |
| `response 407` | CONNECT | Username or password wrong or missing |
| `response 403` | CONNECT | Proxy does not allow this target or port |
| `response 502` | CONNECT | Proxy could not reach the target or resolve its name |
| `SEC_E_CERT_EXPIRED`, `(35)` | TLS | The target site's certificate, not the proxy |
| `< HTTP/1.1 403` after the tunnel | Target | The site refused the request, the proxy did its job |

The same `403` can show up in two places. Before the `CONNECT tunnel established` line, the proxy sent it. After it, the site did. When the site refuses, the fix lies in the site's rules: follow robots.txt, lower your request rate and use the official API if there is one.

## Where the time goes

If a request is slow, the `-w` option prints the moment each stage finished, in seconds. The values add up from the start of the request. The difference between two values is the length of the stage between them.

```bash
curl -s -o /dev/null -x http://user:pass@pr.proxynet.io:8000 \
  -w "dns=%{time_namelookup} tcp=%{time_connect} tls=%{time_appconnect} first_byte=%{time_starttransfer} total=%{time_total} connect_code=%{http_connect}\n" \
  https://example.com
```

Three lines we got through the local proxy:

```text
dns=0.000054 tcp=0.000756 tls=0.052556 first_byte=0.121379 total=0.121455 connect_code=200
dns=0.000064 tcp=0.000718 tls=0.000000 first_byte=0.001487 total=0.001491 connect_code=407
dns=0.000046 tcp=0.000000 tls=0.000000 first_byte=5.015117 total=5.015120 connect_code=000
```

- `dns` is the lookup of the proxy name. The proxy resolves the target's name, so that does not count here.
- The gap between `tcp` and `tls` covers both the `CONNECT` response and the TLS handshake.
- The span from `tls` to `first_byte` is the time the target site needs to prepare its response.
- `0.000000` means the stage was never reached, not that it finished instantly.

The `connect_code` field reports the proxy's tunnel response on its own. The second line shows 407, the third `000`. `000` means no response came from the proxy at all. If the slowdown is between `tls` and `first_byte`, the problem is the target site, not the proxy.

## The same diagnosis in Python

In Python, two settings give you the same visibility. `http.client` debugging prints the headers sent. urllib3 logging prints when the connection opens and how it ends. The basics of proxy setup with Requests are in [How to Use a Proxy With Python Requests: Auth and SOCKS5](/blog/python-requests-proxy).

```python
import http.client
import logging

import requests

# Request sent and headers received go to stdout
http.client.HTTPConnection.debuglevel = 1
# urllib3 connection lines go to stderr, with timestamps
logging.basicConfig(level=logging.DEBUG,
                    format="%(asctime)s %(name)s %(message)s")

proxy = "http://user:pass@pr.proxynet.io:8000"
r = requests.get("https://example.com",
                 proxies={"http": proxy, "https": proxy},
                 timeout=(5, 10))
print(r.status_code)
```

On a successful request, the first lines look like this:

```text
2026-12-01 05:23:54,912 urllib3.connectionpool Starting new HTTPS connection (1): example.com:443
send: b'CONNECT example.com:443 HTTP/1.1\r\nProxy-Authorization: Basic dXNlcjpwYXNz\r\nHost: example.com:443\r\n\r\n'
send: b'GET / HTTP/1.1\r\nHost: example.com\r\nUser-Agent: python-requests/2.34.2\r\n...'
reply: 'HTTP/1.1 200 OK\r\n'
```

Two details change how you read this. First, the status line of the tunnel response is not printed, only its headers. The 407 code is in the exception text: `ProxyError ... Tunnel connection failed: 407 Proxy Authentication Required`. With a closed port the exception is `NewConnectionError`, and on Windows it carries the error code `[WinError 10061]`.

The second is the timeout. We set `timeout=(5, 10)`, and on the silent port the error came back as `ReadTimeout ... (read timeout=5)`. The name says read, but the wait was for the proxy's `CONNECT` response, and the target was never reached. Also, `http.client` writes to stdout and logging writes to stderr. To keep the lines in order, run the script with `python -u`.

## What to include in a support ticket

A support team solves an error fastest when it can find the same request in its own logs. For that, add the following to your ticket:

- **Timestamp and time zone.** `--trace-time` writes local time. Add the time zone or convert to UTC.
- **Proxy address and port.** For example `pr.proxynet.io:8000`.
- **Target domain and port.** The value in the `CONNECT` line is enough, the full URL is not needed.
- **The error line and the last `<` line.** Add the exit code too, but never send it alone.
- **`-w` timings.** For a slowness complaint, they are the only evidence of the stage.
- **Your own IP address the request came from.** Especially needed if you authenticate by IP whitelist.

Remove the password before you send anything. Delete the `user:pass` part of the command and the `Proxy-Authorization` line, or replace them with `***`. Base64 is not encryption: anyone who sees that line can read your password.

## How we tested

We ran the tests on December 1, 2026 on Windows 11. Clients: the curl that ships with Windows, 8.22.0 (Schannel), Python 3.13.17, Requests 2.34.2 and urllib3 2.6.3. The proxy was a local HTTP `CONNECT` proxy we wrote with Python asyncio. It returned 407 for any credentials other than `user:pass`, 403 for ports other than 80 and 443, and 502 for targets it could not reach. A second port accepted connections and never answered.

We ran each scenario with a separate command. The target was `example.com`. For the TLS error we used a test site with an expired certificate. The outputs in this post come from these runs, shortened.

## The bottom line

Run the request with `-v`, find the last `<` line and read the stage from the table. For slowness, look at the `-w` timings, and in Python turn on `debuglevel` and urllib3 logging. Above all, delete the `Proxy-Authorization` line before you share a log. The same lines read in the same order on [Residential Proxy](https://proxynet.io/residential-proxy) connections.

## Sources

- [curl man page, -v, --trace-time, -w and exit codes](https://curl.se/docs/manpage.html): curl.se
- [RFC 9110, HTTP Semantics, section 9.3.6 CONNECT](https://www.rfc-editor.org/rfc/rfc9110#section-9.3.6): rfc-editor.org
- [http.client, HTTPConnection.set_debuglevel](https://docs.python.org/3/library/http.client.html): docs.python.org
- [Logging HOWTO, Basic Logging Tutorial](https://docs.python.org/3/howto/logging.html#logging-basic-tutorial): docs.python.org

## Frequently asked questions

### What do >, < and * mean in curl -v output?

`>` is a header curl sent, `<` is a header it received, and `*` is curl's own note. In an HTTPS request through a proxy, a `>` and `<` pair for `CONNECT` appears first. Then come the `GET` to the target site and the site's response. The last `<` line is the furthest stage the request reached.

### Does a 407 error come from the proxy or the site?

From the proxy. Only a proxy sends 407, and in the output it appears right after the `CONNECT` line. Since the tunnel was never built, the request never reaches the site. Check your username and password. If the password contains characters like `@` or `:`, URL-encode them in the address, or curl will split the address in the wrong place.

### How do I tell if a timeout is at the proxy or the target?

By looking at the last `<` line. If `CONNECT` went out and no response came, the wait is on the proxy side. If `200 Connection established` arrived and the wait came after it, the slowdown is at the target site. The `-w` output shows the same split: `connect_code=000` points to the proxy, a large gap between `tls` and `first_byte` points to the target.

### Is it safe to share curl -v output?

No, not without cleaning it. The `Proxy-Authorization` line carries the username and password in base64, and one command decodes it. The `user:pass` part of the command also holds the password in plain text. Delete both or replace them with asterisks. The target domain, the time and the error line are enough for a diagnosis.

### How do I turn on a detailed log for proxy requests in Python?

With two lines. `http.client.HTTPConnection.debuglevel = 1` prints the headers sent and the response received to stdout. `logging.basicConfig(level=logging.DEBUG)` turns on urllib3's connection lines. The tunnel error code shows up in the exception text, for example `Tunnel connection failed: 407`. Run the script with `python -u` so the lines stay in order.

### What does 0.000000 mean in curl -w output?

It means that stage was never reached. In our test, a wrong password gave `tls=0.000000`, because TLS never started without a tunnel. With the silent proxy, `tcp` and `tls` stayed at zero and `connect_code=000` came back. Do not read a zero as a fast stage. Read it as a missing one.
