HTTP/3 & UDP
Updated:
IPv4 and ISP proxies carry UDP traffic over SOCKS5. Use it to open websites over HTTP/3 (QUIC) from your proxy's IP, and to route any other UDP protocol: DNS, WebRTC, VoIP, online games.
Works on every IPv4 and ISP proxy you already have — same IP, same SOCKS5 port, same login and password. There is nothing to enable and nothing to order.
This page covers IPv4 and ISP proxies. For residential proxies, see HTTP/3 & UDP over SOCKS5. IPv6, mobile, shared and rotating proxies do not carry UDP.
How it works
HTTP/3 runs over QUIC, and QUIC runs over UDP. The HTTP proxy protocol carries TCP only, so UDP traffic goes through SOCKS5.
Traffic | HTTP proxy | SOCKS5 |
|---|---|---|
TCP: HTTP/1.1, HTTP/2, any other TCP protocol | ✅ | ✅ |
UDP: HTTP/3 (QUIC), DNS, WebRTC, VoIP, games | — | ✅ |
Three exchanges happen before the first datagram leaves your machine:
Connect and authenticate
Your app opens a SOCKS5 connection to your proxy and logs in with your login and password, or is let in by your authorized IP.
Request a UDP relay
It sends a
UDP ASSOCIATErequest (RFC 1928). The proxy answers with the relay address: your proxy's IP and port, the same ones you connected to.Send datagrams
The app sends UDP datagrams to the relay address. Each datagram starts with a short SOCKS5 header naming the destination. The traffic leaves from your proxy's IP, the same IP your TCP traffic uses, and the answers come back the same way.
The relay lives only as long as the SOCKS5 connection from the first step stays open.
Connection settings
Setting | Value |
|---|---|
Protocol | SOCKS5 with username/password authentication, or IP authorization |
Host | the IP of your proxy |
Port | the SOCKS5 port of your proxy |
Login and password | the login and password of your proxy |
UDP relay | the address and port from the |
Exit IP | the IP of your proxy, the same for UDP and TCP |
Firewall | allow outgoing UDP to your proxy's IP, on its SOCKS5 port and on ports 63000-63999 |
Your proxy has an HTTP(S) port and a SOCKS5 port. To move a connection string to SOCKS5, change the scheme and take the SOCKS5 port:
http://LOGIN:PASSWORD@IP:HTTP_PORT
socks5h://LOGIN:PASSWORD@IP:SOCKS5_PORTUse socks5h://, not socks5://. With socks5h:// the proxy resolves domain names. With socks5:// your machine resolves them, and if it picks an IPv6 address the request hangs until it times out: IPv4 and ISP proxies carry IPv4 traffic only, and UDP has no way to report an error. If your app can only use socks5://, make it use IPv4 addresses.
To get ready-made lines from the API, export your proxies with proto=socks5: every line then carries the SOCKS5 port, as login:password@IP:port. Put socks5h:// in front of it. For ISP proxies, use isp instead of ipv4; for mixed orders, mix or mix_isp:
GET https://proxy-seller.com/personal/api/v2/{YourApiKey}/proxy/download/ipv4?ext=txt&proto=socks5All export parameters are described in Export IPs in txt/csv/custom.
When the relay port differs
One proxy port serves all UDP sessions that one login opens from one IP of yours, up to 64 at a time. If a second login of yours opens a session on the same proxy from the same IP, or you open more than 64 sessions, the proxy gives the new session a port of its own in the range 63000-63999, on the same IP, and names it in the reply.
Always send datagrams to the address and port from the reply, never to the proxy port you connected to. Apps that follow RFC 1928 do. An app that ignores the reply stops working in this case.
Check it yourself
Check the connection
curl --proxy socks5h://LOGIN:PASSWORD@IP:SOCKS5_PORT https://cloudflare-quic.com/cdn-cgi/traceip=in the answer is the IP of your proxy.http=http/2means the request went over TCP.Check UDP
This Python script, standard library only, opens a UDP relay and asks OpenDNS for your IP. Save it as
udp_check.py, fill in the four settings at the top and runpython udp_check.py.#!/usr/bin/env python3 """Check that UDP works through your proxy. Asks OpenDNS "what is my IP?" over a SOCKS5 UDP relay. If UDP works, the answer is the IP of your proxy. Python 3, standard library only. """ import random import socket import struct PROXY_HOST = "203.0.113.10" # the IP of your proxy PROXY_PORT = 50101 # the SOCKS5 port of your proxy LOGIN = "LOGIN" PASSWORD = "PASSWORD" def recv_exact(sock, n): data = b"" while len(data) < n: chunk = sock.recv(n - len(data)) if not chunk: raise ConnectionError("the proxy closed the connection") data += chunk return data # 1. Connect and authenticate (RFC 1928 and RFC 1929). Keep this connection open # for as long as you use UDP: the relay lives exactly as long as it does. control = socket.create_connection((PROXY_HOST, PROXY_PORT), timeout=10) control.sendall(b"\x05\x01\x02") # SOCKS5, one method: username/password if recv_exact(control, 2) != b"\x05\x02": raise SystemExit("the proxy did not accept username/password authentication") user, password = LOGIN.encode(), PASSWORD.encode() control.sendall(b"\x01" + bytes([len(user)]) + user + bytes([len(password)]) + password) if recv_exact(control, 2) != b"\x01\x00": raise SystemExit("wrong login or password") # 2. Ask for a UDP relay. 0.0.0.0:0 means "I do not know my UDP address yet". control.sendall(b"\x05\x03\x00\x01" + bytes(4) + bytes(2)) reply = recv_exact(control, 4) if reply[1] != 0: raise SystemExit("UDP ASSOCIATE refused, reply code 0x%02x" % reply[1]) if reply[3] == 1: # the relay address: an IPv4 address, a name or an IPv6 address relay_host = socket.inet_ntoa(recv_exact(control, 4)) elif reply[3] == 3: relay_host = recv_exact(control, recv_exact(control, 1)[0]).decode() else: relay_host = socket.inet_ntop(socket.AF_INET6, recv_exact(control, 16)) relay_port = struct.unpack(">H", recv_exact(control, 2))[0] if relay_host in ("0.0.0.0", "::"): # "the address you already know" relay_host = PROXY_HOST print("UDP relay: %s:%d" % (relay_host, relay_port)) # 3. Send a DNS query inside a SOCKS5 UDP datagram. Send it to the relay address from # step 2, not to the proxy port you connected to: they may differ. query = struct.pack(">HHHHHH", random.randint(0, 0xFFFF), 0x0100, 1, 0, 0, 0) for label in "myip.opendns.com".split("."): query += bytes([len(label)]) + label.encode() query += b"\x00" + struct.pack(">HH", 1, 1) # type A, class IN # SOCKS5 UDP header: RSV(2) FRAG(1) ATYP(1) DST.ADDR DST.PORT, then the data. header = b"\x00\x00\x00\x01" + socket.inet_aton("208.67.222.222") + struct.pack(">H", 53) udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) udp.settimeout(10) udp.sendto(header + query, (relay_host, relay_port)) try: data, _ = udp.recvfrom(4096) except socket.timeout: raise SystemExit("no answer in 10 seconds: see Troubleshooting") # The answer comes in the same kind of header; for an IPv4 source it is 10 bytes long. print("Your UDP traffic leaves from", socket.inet_ntoa(data[-4:])) control.close()Example output:
UDP relay: 203.0.113.10:50101 Your UDP traffic leaves from 203.0.113.10The IP in the last line is the IP of your proxy.
Send an HTTP/3 request
With curl_cffi 0.17 or newer. Install it, save the script as
h3_curl_cffi.py, fill in the four settings at the top and run it:pip install "curl_cffi>=0.17" python h3_curl_cffi.py#!/usr/bin/env python3 """HTTP/3 through your proxy with curl_cffi. pip install "curl_cffi>=0.17" """ from curl_cffi import requests PROXY_HOST = "203.0.113.10" # the IP of your proxy PROXY_PORT = 50101 # the SOCKS5 port of your proxy LOGIN = "LOGIN" PASSWORD = "PASSWORD" response = requests.get( "https://cloudflare-quic.com/cdn-cgi/trace", # socks5h: the proxy resolves the name. Plain socks5 resolves it on your machine, and # if that gives an IPv6 address the request times out: see Limitations. proxy="socks5h://%s:%s@%s:%d" % (LOGIN, PASSWORD, PROXY_HOST, PROXY_PORT), http_version="v3only", # QUIC only, no fallback to TCP impersonate="chrome", timeout=30, ) print(response.text) # http=http/3 means the site was reached over HTTP/3; ip= is your proxyWith aioquic, a QUIC library that does its own I/O, so you can see how every QUIC packet travels inside a SOCKS5 datagram. It needs Python 3.11 or newer:
pip install aioquic python h3_aioquic.py#!/usr/bin/env python3 """HTTP/3 through your proxy with aioquic (Python 3.11+). pip install aioquic""" import socket import struct import time from aioquic.h3.connection import H3Connection from aioquic.h3.events import DataReceived, HeadersReceived from aioquic.quic.configuration import QuicConfiguration from aioquic.quic.connection import QuicConnection from aioquic.quic.events import ConnectionTerminated PROXY_HOST = "203.0.113.10" # the IP of your proxy PROXY_PORT = 50101 # the SOCKS5 port of your proxy LOGIN = "LOGIN" PASSWORD = "PASSWORD" TARGET_HOST, TARGET_PORT, TARGET_PATH = "cloudflare-quic.com", 443, "/cdn-cgi/trace" def recv_exact(sock, n): data = b"" while len(data) < n: chunk = sock.recv(n - len(data)) if not chunk: raise ConnectionError("the proxy closed the connection") data += chunk return data # 1. Connect, authenticate, ask for a UDP relay (see the check above). Keep `control` open. control = socket.create_connection((PROXY_HOST, PROXY_PORT), timeout=10) control.sendall(b"\x05\x01\x02") if recv_exact(control, 2) != b"\x05\x02": raise SystemExit("the proxy did not accept username/password authentication") user, password = LOGIN.encode(), PASSWORD.encode() control.sendall(b"\x01" + bytes([len(user)]) + user + bytes([len(password)]) + password) if recv_exact(control, 2) != b"\x01\x00": raise SystemExit("wrong login or password") control.sendall(b"\x05\x03\x00\x01" + bytes(4) + bytes(2)) reply = recv_exact(control, 4) if reply[1] != 0: raise SystemExit("UDP ASSOCIATE refused, reply code 0x%02x" % reply[1]) if reply[3] == 1: relay_host = socket.inet_ntoa(recv_exact(control, 4)) elif reply[3] == 3: relay_host = recv_exact(control, recv_exact(control, 1)[0]).decode() else: relay_host = socket.inet_ntop(socket.AF_INET6, recv_exact(control, 16)) relay_port = struct.unpack(">H", recv_exact(control, 2))[0] if relay_host in ("0.0.0.0", "::"): relay_host = PROXY_HOST # 2. Every QUIC packet travels inside a SOCKS5 UDP datagram. The target is named by # its domain, so the proxy resolves it (the same as socks5h:// in curl). udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) name = TARGET_HOST.encode() HEADER = b"\x00\x00\x00\x03" + bytes([len(name)]) + name + struct.pack(">H", TARGET_PORT) def strip_header(datagram): atyp = datagram[3] if atyp == 1: return datagram[10:] if atyp == 4: return datagram[22:] return datagram[7 + datagram[4]:] # 3. A QUIC connection that does its own I/O, and an HTTP/3 request on it. config = QuicConfiguration(is_client=True, alpn_protocols=["h3"], server_name=TARGET_HOST) quic = QuicConnection(configuration=config) peer = (TARGET_HOST, TARGET_PORT) quic.connect(peer, now=time.monotonic()) http = H3Connection(quic) stream_id = quic.get_next_available_stream_id() http.send_headers( stream_id, [ (b":method", b"GET"), (b":scheme", b"https"), (b":authority", name), (b":path", TARGET_PATH.encode()), (b"user-agent", b"aioquic-over-socks5-udp"), ], end_stream=True, ) body, status, finished = b"", None, False deadline = time.monotonic() + 20 while not finished and time.monotonic() < deadline: for packet, _ in quic.datagrams_to_send(now=time.monotonic()): udp.sendto(HEADER + packet, (relay_host, relay_port)) timer = quic.get_timer() udp.settimeout(max(0.01, min(1.0, timer - time.monotonic())) if timer else 1.0) try: datagram, _ = udp.recvfrom(65535) quic.receive_datagram(strip_header(datagram), peer, now=time.monotonic()) except socket.timeout: pass timer = quic.get_timer() if timer is not None and timer <= time.monotonic(): quic.handle_timer(now=time.monotonic()) while (event := quic.next_event()) is not None: if isinstance(event, ConnectionTerminated): raise SystemExit("QUIC connection closed: %s" % event.reason_phrase) for h3_event in http.handle_event(event): if isinstance(h3_event, HeadersReceived): status = dict(h3_event.headers).get(b":status") elif isinstance(h3_event, DataReceived): body += h3_event.data finished = finished or h3_event.stream_ended if not finished: raise SystemExit("no response in 20 seconds: see Troubleshooting") print("status:", status.decode() if status else "?") print(body.decode()) # http=http/3 means the site was reached over HTTP/3; ip= is your proxy control.close()Both scripts print the Cloudflare trace page. Output (shortened):
ip=203.0.113.10 http=http/3http=http/3means the website received the request over HTTP/3.ip=is your proxy's IP.
Plain curl cannot do this: it refuses HTTP/3 over a SOCKS proxy.
HTTP/3 in browsers and other apps
An app can send UDP through a proxy only if it supports UDP ASSOCIATE.
Chrome and Firefox do not send UDP through the SOCKS5 proxy set in their own settings, so sites open over HTTP/2 or HTTP/1.1.
To get HTTP/3, route the app's traffic through a tool that forwards UDP over SOCKS5. We tested the configs below with sing-box 1.14, mihomo 1.19 and Xray 26.11.
sing-box 1.12 or newer, on Windows, macOS and Linux. The tun inbound needs administrator or root rights. Every app on the machine goes through the proxy, UDP included, and DNS goes through it too.
{
"dns": {
"servers": [
{ "type": "udp", "tag": "remote", "server": "1.1.1.1", "detour": "proxy" }
],
"strategy": "ipv4_only"
},
"inbounds": [
{ "type": "tun", "address": ["172.19.0.1/30"], "auto_route": true, "strict_route": true }
],
"outbounds": [
{
"type": "socks",
"tag": "proxy",
"server": "203.0.113.10",
"server_port": 50101,
"version": "5",
"username": "LOGIN",
"password": "PASSWORD"
},
{ "type": "direct", "tag": "direct" }
],
"route": {
"auto_detect_interface": true,
"final": "proxy",
"rules": [
{ "action": "sniff" },
{ "protocol": "dns", "action": "hijack-dns" }
]
}
}The TUN has IPv4 addresses only and DNS answers are limited to IPv4, so apps do not try IPv6 addresses.
mixed-port: 7890
ipv6: false
dns:
enable: true
ipv6: false
respect-rules: true
default-nameserver:
- 1.1.1.1
proxy-server-nameserver:
- 1.1.1.1
nameserver:
- 1.1.1.1
tun:
enable: true
stack: gvisor
auto-route: true
auto-detect-interface: true
dns-hijack:
- any:53
proxies:
- name: proxy
type: socks5
server: 203.0.113.10
port: 50101
username: LOGIN
password: PASSWORD
udp: true
rules:
- MATCH,proxyipv6: false does the same as above: it keeps apps on IPv4.
Xray runs a local SOCKS5 server with UDP and forwards everything to your proxy. Point an app that supports SOCKS5 UDP at socks5h://127.0.0.1:1080.
{
"inbounds": [
{
"listen": "127.0.0.1",
"port": 1080,
"protocol": "socks",
"settings": { "auth": "noauth", "udp": true, "ip": "127.0.0.1" }
}
],
"outbounds": [
{
"protocol": "socks",
"settings": { "address": "203.0.113.10", "port": 50101, "user": "LOGIN", "pass": "PASSWORD" }
}
]
}Windows. ProxiFyre forwards the UDP of selected apps over SOCKS5. Point it at the SOCKS5 port of your proxy and set its supported address families to IPv4 only. Proxifier's documentation describes TCP connections only, so we do not recommend it for HTTP/3.
Not suitable
The Dante socksify wrapper works with programs that use plain UDP sockets, but not with dig or with the HTTP/3 client we tried. Use one of the tools above.
Limitations
UDP works only over SOCKS5. HTTP proxy connections carry TCP only.
Connecting to the proxy itself over HTTPS (TLS) or HTTP/3 is not supported. Use
http://,socks5://orsocks5h://.An app that asks an
http://proxy for HTTP/3 (CONNECT-UDP) gets403. If the app may fall back to TCP, for example curl_cffi withhttp_version="v3", it uses HTTP/2 instead.UDP is available on IPv4 and ISP proxies, through their SOCKS5 port. It is not available on IPv6, mobile, shared and rotating proxies:
UDP ASSOCIATEis refused there, as before.Destinations are IPv4 addresses and domain names that resolve to IPv4. Datagrams to an IPv6 address are dropped, and your app times out.
The
BINDcommand is not supported.The relay lives as long as the SOCKS5 connection. Close it and the session ends. Keep it open while you use UDP.
Send the first datagram within 10 seconds of the reply, or the proxy closes the session. A session with no UDP traffic for 30 minutes is closed too.
UDP must come from the same public IP as the SOCKS5 connection. Datagrams from any other IP are ignored. This can break UDP behind a NAT that uses several public IPs.
A destination (IP and port) is released after 30 seconds without packets if it never answered, and after 2 minutes without packets once it has. Port 53 (DNS) is always released after 30 seconds. Answers from a released destination are dropped until you send to it again.
Answers are accepted only from the IP and port you sent to. Packets from any other host are dropped, so you cannot accept incoming connections.
The SOCKS5 header of an answer names the destination by its IP address, also when you sent to a domain name.
The proxy learns your UDP source port from your first datagram, or from the port you declared in the
UDP ASSOCIATErequest. If your NAT later moves you to another port, the proxy follows it once the old port has been silent for 30 seconds.A datagram can be up to 4096 bytes including the SOCKS5 header, about 4086 bytes of data to an IPv4 address. A bigger one is dropped. SOCKS5 fragmentation (
FRAGother than 0) is not supported. Answers from destinations can be up to about 64 KB.ICMP errors (port unreachable and the like) are not passed to you. A closed port looks like silence.
These destinations are blocked, and datagrams to them are dropped without an answer:
UDP ports 0, 7, 17, 19, 69, 111, 137-139, 161-162, 389, 427, 445, 520, 623, 1434, 1900, 3283, 3702, 5353, 5355, 5683, 10001, 10074, 11211 and 37810;
ports 25, 465 and 587, as for TCP;
private, loopback, link-local (including 169.254.169.254), multicast, broadcast and other reserved addresses, as for TCP. A DNS server on your local network is a private address: use a public one such as
1.1.1.1;the addresses of the proxy server itself.
Rates and counts
What | Limit |
|---|---|
Packets you send, per UDP session | 25,000 per second |
Packets you send, all your sessions on one server | 100,000 per second |
Destinations, per UDP session | 1,024 |
Destinations, all your sessions on one server | 8,192 |
A destination that never answers | after 256 packets without any answer from its IP, 20 packets per second until it answers |
UDP sessions on one proxy port, from one IP of yours | 64 |
UDP sessions on a port of their own (63000-63999), from one IP of yours, per proxy IP | 64 |
Your plan's limits
UDP is held to the limits of your plan as TCP is:
the speed limit is shared with the TCP traffic of the same login;
the SOCKS5 connection of a session and every destination count as connections toward the connection limit of your proxy;
a new destination counts as a new request toward the requests-per-second limit, if your proxy has one;
UDP traffic is counted by its data, without SOCKS5 headers, and goes toward your traffic and fair-use limits like TCP traffic;
if your IP is banned on the proxy or your traffic runs out, your UDP sessions end.
FAQ
No. UDP and HTTP/3 work on your existing IPv4 and ISP proxies with the same login and password.
No. HTTP and SOCKS5 over TCP work as before.
Make sure nothing blocks outgoing UDP to your proxy's IP, on its SOCKS5 port and on ports 63000-63999.
Keep the SOCKS5 TCP connection open while you send UDP.
Send datagrams to the address and port from the
UDP ASSOCIATEreply.Send the first datagram within 10 seconds of the reply.
Send to IPv4 addresses, or to domain names with
socks5h://.Use a public DNS server, not one on your local network.
If your network has several public IPs for outgoing traffic, UDP must leave from the same IP as the SOCKS5 connection.
Your machine resolved the name to an IPv6 address, which IPv4 and ISP proxies do not carry. Use socks5h:// so the proxy resolves the name, or make your app use IPv4.
Reply code
0x07(command not supported), or the connection simply closes: UDP is not available on this proxy. Contact support.Reply code
0x30: you reached the connection limit of your proxy. Every UDP session holds one connection, and so does every destination.
Your app does not send UDP through the proxy, or the website does not offer HTTP/3. A browser starts on TCP and switches to HTTP/3 after the site announces it, so reload the page.