XTLS/Xray-core · error
failed to create UDP connection
Error message
failed to create UDP connection
What it means
SOCKS client Process fails establishing the UDP associate connection through the dialer for a UDP request; the chained error means the UDP relay setup to the SOCKS server failed, so datagrams cannot be forwarded.
Solutions
- Check .Base(err) for the UDP dial failure
- Ensure the path to the SOCKS server supports UDP and the server allows UDP associate
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at proxy/socks/client.go:149 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/9d3588cfb85d99ba.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/socks/client.go:149
}
}, p.Timeouts.ConnectionIdle)
var requestFunc func() error
var responseFunc func() error
if request.Command == protocol.RequestCommandTCP {
requestFunc = func() error {
defer timer.SetTimeout(p.Timeouts.DownlinkOnly)
return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer))
}
responseFunc = func() error {
ob.CanSpliceCopy = 1
defer timer.SetTimeout(p.Timeouts.UplinkOnly)
return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer))
}
} else if request.Command == protocol.RequestCommandUDP {
udpConn, err := dialer.Dial(ctx, udpRequest.Destination())
if err != nil {
return errors.New("failed to create UDP connection").Base(err)
}
defer udpConn.Close()
requestFunc = func() error {
defer timer.SetTimeout(p.Timeouts.DownlinkOnly)
writer := &UDPWriter{Writer: udpConn, Request: request}
return buf.Copy(link.Reader, writer, buf.UpdateActivity(timer))
}
responseFunc = func() error {
ob.CanSpliceCopy = 1
defer timer.SetTimeout(p.Timeouts.UplinkOnly)
reader := &UDPReader{Reader: udpConn}
return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer))
}
}
if newCtx != nil {
ctx = newCtx
}View on GitHub (pinned to 7d214f8b09)