{"record":{"id":"a94bdfcb9a3239ec","repo":"XTLS/Xray-core","slug":"trojan-server-address-is-not-set","errorCode":null,"errorMessage":"Trojan server address is not set.","messagePattern":"Trojan server address is not set\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/trojan.go","lineNumber":65,"sourceCode":"\t\t\t{\n\t\t\t\tAddress:  c.Address,\n\t\t\t\tPort:     c.Port,\n\t\t\t\tLevel:    c.Level,\n\t\t\t\tEmail:    c.Email,\n\t\t\t\tPassword: c.Password,\n\t\t\t\tFlow:     c.Flow,\n\t\t\t},\n\t\t}\n\t}\n\tif len(c.Servers) != 1 {\n\t\treturn nil, errors.New(`Trojan settings: \"servers\" should have one and only one member. Multiple endpoints in \"servers\" should use multiple Trojan outbounds and routing balancer instead`)\n\t}\n\n\tconfig := &trojan.ClientConfig{}\n\n\tfor _, rec := range c.Servers {\n\t\tif rec.Address == nil {\n\t\t\treturn nil, errors.New(\"Trojan server address is not set.\")\n\t\t}\n\t\tif rec.Port == 0 {\n\t\t\treturn nil, errors.New(\"Invalid Trojan port.\")\n\t\t}\n\t\tif rec.Password == \"\" {\n\t\t\treturn nil, errors.New(\"Trojan password is not specified.\")\n\t\t}\n\t\tif rec.Flow != \"\" {\n\t\t\treturn nil, errors.PrintRemovedFeatureError(`Flow for Trojan`, ``)\n\t\t}\n\n\t\tconfig.Server = &protocol.ServerEndpoint{\n\t\t\tAddress: rec.Address.Build(),\n\t\t\tPort:    uint32(rec.Port),\n\t\t\tUser: &protocol.User{\n\t\t\t\tLevel: uint32(rec.Level),\n\t\t\t\tEmail: rec.Email,\n\t\t\t\tAccount: serial.ToTypedMessage(&trojan.Account{","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/trojan.go#L47-L83","documentation":"Thrown when iterating the single Trojan server entry and its 'address' field is nil (missing or null in JSON). The address is mandatory — the Trojan client must know where to connect.","triggerScenarios":"A servers entry like { \"port\": 443, \"password\": \"x\" } with no \"address\" key, or \"address\": null.","commonSituations":"Templating a config and leaving the address placeholder empty, or accidentally renaming the key (e.g. \"server\" or \"host\") instead of \"address\".","solutions":["Add \"address\": \"your.server.example\" to the servers entry","Verify the key name is exactly \"address\" (not \"server\"/\"host\"/\"addr\")","If using the legacy flat form, set the top-level \"address\" field"],"exampleFix":"// before\n{ \"port\": 443, \"password\": \"secret\" }\n// after\n{ \"address\": \"trojan.example.com\", \"port\": 443, \"password\": \"secret\" }","handlingStrategy":"validation","validationCode":"for _, s := range servers {\n    if !gjson.Valid(s.Raw) || gjson.Get(s.Raw, \"address\").Type != gjson.String {\n        return errors.New(\"trojan server entry is missing a string \\\"address\\\"\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast in generators when any required endpoint field is empty","Use the exact key name \"address\""],"tags":["config","trojan","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}