{"record":{"id":"1a55c44f2d80210f","repo":"XTLS/Xray-core","slug":"failed-to-get-server-spec","errorCode":null,"errorMessage":"failed to get server spec","messagePattern":"failed to get server spec","errorType":"validation","errorClass":"errors.Error","httpStatus":null,"severity":"critical","filePath":"proxy/http/client.go","lineNumber":57,"sourceCode":"\ntype h2Conn struct {\n\trawConn net.Conn\n\th2Conn  *http2.ClientConn\n}\n\nvar (\n\tcachedH2Mutex sync.Mutex\n\tcachedH2Conns map[net.Destination]h2Conn\n)\n\n// NewClient create a new http client based on the given config.\nfunc NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {\n\tif config.Server == nil {\n\t\treturn nil, errors.New(`no target server found`)\n\t}\n\tserver, err := protocol.NewServerSpecFromPB(config.Server)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to get server spec\").Base(err)\n\t}\n\n\tv := core.MustFromContext(ctx)\n\treturn &Client{\n\t\tserver:        server,\n\t\tpolicyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),\n\t\theader:        config.Header,\n\t}, nil\n}\n\n// Process implements proxy.Outbound.Process. We first create a socket tunnel via HTTP CONNECT method, then redirect all inbound traffic to that tunnel.\nfunc (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {\n\toutbounds := session.OutboundsFromContext(ctx)\n\tob := outbounds[len(outbounds)-1]\n\tif !ob.Target.IsValid() {\n\t\treturn errors.New(\"target not specified.\")\n\t}\n\tob.Name = \"http\"","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/http/client.go#L39-L75","documentation":"protocol.NewServerSpecFromPB failed to convert the protobuf server entry into an internal server spec. This validates address/port/user fields of the configured HTTP proxy server; malformed address, invalid port, or bad user credentials shape are the usual causes. The parse error is chained via .Base(err).","triggerScenarios":"settings.servers[0] contains an invalid address (empty string, bad host), port 0/out-of-range, or a users entry with an unsupported encryption/credential format for the HTTP outbound.","commonSituations":"Copy-pasted server entry from a SOCKS example into an HTTP outbound, port typed as string in hand-written JSON, leftover cipher fields from older configs.","solutions":["Read the Base error — it names the invalid field","Ensure address is a valid host/IP and port is an integer in 1-65535","For authenticated proxies keep users entries to {\"user\",\"pass\"}; remove protocol-specific fields that don't apply to HTTP","Validate with `xray run -test -c config.json`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"```go\nif _, err := protocol.NewServerSpecFromPB(cfg.Server); err != nil {\n    // fix address/port/users before constructing the outbound\n}\n```","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate host and 1-65535 port ranges in config tooling","Keep HTTP users entries minimal (user/pass)","Run `xray run -test` on generated configs"],"tags":["http-outbound","server-spec","config","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}