UDP ASSOCIATE command (RFC 1928, section 7), on the same host, SOCKS5 port, and credentials you use for CONNECT (see Authentication).
curl cannot send UDP through a SOCKS5 proxy. Use a library that supports SOCKS5 UDP ASSOCIATE (see the example below).
How it works
- Open a TCP connection to the proxy, authenticate, and send
UDP ASSOCIATE. - The reply carries a relay address,
BND.ADDR:BND.PORT. Prefix each datagram with the SOCKS5 UDP header (RSV RSV FRAG ATYP DST.ADDR DST.PORT) and send it to that address. Replies arrive from the same address, carrying the source address in the same header. - Keep the TCP connection open while you use the association. Closing it ends the association.
Sticky sessions
An association uses one exit IP for its whole life. Add a session identifier to keep that same IP across the session’s TCP and UDP traffic; without one, each association gets its own IP.Limitations
- Same source IP. Datagrams must come from the same public IP as the TCP connection; others are dropped. Behind carrier-grade NAT or a multi-WAN setup, UDP may leave from a different public IP than TCP, which breaks the association.
- Timing. Send the first datagram within 60 seconds of the reply. The association ends when the TCP connection closes, after 2 minutes without traffic either way, or if its exit server goes offline — then open a new one.
- Ports and destinations. Same restrictions as TCP: ports 80 and 443 only, no private or blocked destinations. A datagram that breaks a rule is dropped silently, because SOCKS5 has no per-datagram error.
- Two-way only, unfragmented. A destination that never answers receives at most the first 32 datagrams (64 KiB), so one-way UDP does not work;
FRAGmust be zero. - Size and encryption. The SOCKS5 header adds up to 262 bytes; the full datagram, header included, must fit the path MTU to the proxy, so keep payloads at or below the QUIC default (~1,200 bytes). Datagrams are not encrypted at the proxy — QUIC and HTTP/3 provide their own encryption end to end.
UDP counts toward your usage like TCP: datagram payload in both directions. SOCKS5 headers are not counted.
HTTP/3 in browsers
Name resolution through the proxy does not return the records that advertise HTTP/3, so a browser loads a site over HTTP/2 first and switches to HTTP/3 on the next load via itsAlt-Svc header. Test with at least two page loads.
Errors
If the proxy cannot set up the association, it answersUDP ASSOCIATE with an error reply and closes the connection — there is no fallback to TCP.
Example
For the SOCKS5 UDP layer use PySocks in Python or thesocks package in Node.js; for QUIC or HTTP/3 on top, drive the proxied socket with aioquic (Python) or quic-go (Go). No mainstream library does the whole HTTP/3-over-SOCKS5 stack on its own.
With PySocks, bind() runs the UDP ASSOCIATE handshake and send/recv frame the datagrams. This example sends a QUIC Initial with a reserved version, which any QUIC server answers with a Version Negotiation packet, confirming the UDP path end to end. For real traffic, hand s to a QUIC/HTTP3 client such as aioquic.