{"record":{"id":"ed0846dd6a71e3bf","repo":"XTLS/Xray-core","slug":"udp-is-not-enabled","errorCode":null,"errorMessage":"UDP is not enabled.","messagePattern":"UDP is not enabled\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/socks/protocol.go","lineNumber":174,"sourceCode":"\t\t\tbuffer.Release()\n\t\t\treturn nil, nil, errors.New(\"failed to read request\").Base(err)\n\t\t}\n\t\tcmd = buffer.Byte(1)\n\t\tbuffer.Release()\n\t}\n\n\trequest := new(protocol.RequestHeader)\n\tif username != \"\" {\n\t\trequest.User = &protocol.MemoryUser{Email: username}\n\t}\n\tswitch cmd {\n\tcase cmdTCPConnect, cmdTorResolve, cmdTorResolvePTR:\n\t\t// We don't have a solution for Tor case now. Simply treat it as connect command.\n\t\trequest.Command = protocol.RequestCommandTCP\n\tcase cmdUDPAssociate:\n\t\tif !s.config.UdpEnabled {\n\t\t\twriteSocks5Response(writer, statusCmdNotSupport, net.AnyIP, net.Port(0))\n\t\t\treturn nil, nil, errors.New(\"UDP is not enabled.\")\n\t\t}\n\t\trequest.Command = protocol.RequestCommandUDP\n\tcase cmdTCPBind:\n\t\twriteSocks5Response(writer, statusCmdNotSupport, net.AnyIP, net.Port(0))\n\t\treturn nil, nil, errors.New(\"TCP bind is not supported.\")\n\tdefault:\n\t\twriteSocks5Response(writer, statusCmdNotSupport, net.AnyIP, net.Port(0))\n\t\treturn nil, nil, errors.New(\"unknown command \", cmd)\n\t}\n\n\trequest.Version = socks5Version\n\n\taddr, port, err := addrParser.ReadAddressPort(nil, reader)\n\tif err != nil {\n\t\treturn nil, nil, errors.New(\"failed to read address\").Base(err)\n\t}\n\trequest.Address = addr\n\trequest.Port = port","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/socks/protocol.go#L156-L192","documentation":"Thrown in handshake5 (proxy/socks/protocol.go:174) when a client sends CMD=0x03 (UDP ASSOCIATE) but the inbound's ServerConfig.UdpEnabled is false. The server replies with statusCmdNotSupport and rejects the request: the inbound was configured without UDP support.","triggerScenarios":"Inbound socks config lacks \"udp\": true while the client (browser with DNS-over-proxy, game, VoIP app) issues UDP ASSOCIATE; also tproxy/transparent setups that rely on SOCKS UDP.","commonSituations":"Default inbound templates that omit the udp field; switching a client from TCP-only to full proxying; forgetting that the remote outbound also needs UDP capability for end-to-end UDP.","solutions":["Add \"udp\": true to the socks inbound settings in config.json and restart/reload Xray.","Verify the outbound(s) used by routing also support UDP (e.g. freedom, vmess, vless generally do).","If UDP must stay disabled, configure the client application to not use the proxy for UDP traffic."],"exampleFix":"// before\n{ \"inbounds\": [{ \"port\": 1080, \"protocol\": \"socks\", \"settings\": { \"auth\": \"noauth\" } }] }\n\n// after\n{ \"inbounds\": [{ \"port\": 1080, \"protocol\": \"socks\", \"settings\": { \"auth\": \"noauth\", \"udp\": true } }] }","handlingStrategy":"validation","validationCode":"// Client-side / deployment check: confirm the inbound allows UDP before issuing UDP ASSOCIATE\nif appNeedsUDP && !inboundSettings.UDP {\n    return fmt.Errorf(\"SOCKS inbound has udp=false; enable \\\"udp\\\": true or route UDP directly\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"UDP is not enabled\") {\n    return fmt.Errorf(\"server rejected UDP ASSOCIATE: set \\\"udp\\\": true on the socks inbound\")\n}","preventionTips":["Set \"udp\": true on SOCKS inbounds that serve browsers, games, or VoIP.","Ensure the routed outbound also supports UDP.","Include a config lint step that flags udp-dependent clients against non-UDP inbounds."],"tags":["socks","socks5","udp","config","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}