XTLS/Xray-core · error
Trojan password is not specified.
Error message
Trojan password is not specified.
What it means
Thrown when the Trojan server entry's 'password' is an empty string. The Trojan protocol authenticates purely by password hash, so an empty password makes the account unusable and the config is rejected at build time.
Source
Thrown at infra/conf/trojan.go:71
Flow: c.Flow,
},
}
}
if len(c.Servers) != 1 {
return 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`)
}
config := &trojan.ClientConfig{}
for _, rec := range c.Servers {
if rec.Address == nil {
return nil, errors.New("Trojan server address is not set.")
}
if rec.Port == 0 {
return nil, errors.New("Invalid Trojan port.")
}
if rec.Password == "" {
return nil, errors.New("Trojan password is not specified.")
}
if rec.Flow != "" {
return nil, errors.PrintRemovedFeatureError(`Flow for Trojan`, ``)
}
config.Server = &protocol.ServerEndpoint{
Address: rec.Address.Build(),
Port: uint32(rec.Port),
User: &protocol.User{
Level: uint32(rec.Level),
Email: rec.Email,
Account: serial.ToTypedMessage(&trojan.Account{
Password: rec.Password,
}),
},
}
breakView on GitHub (pinned to 7d214f8b09)
Solutions
- Set "password" to the value configured on the Trojan server
- If using env substitution, verify the variable resolves before Xray loads the config (xray run -c config.json after substitution)
Example fix
// before
{ "address": "trojan.example.com", "port": 443, "password": "" }
// after
{ "address": "trojan.example.com", "port": 443, "password": "your-password" } Defensive patterns
Strategy: validation
Validate before calling
if gjson.Get(serverRaw, "password").String() == "" {
return errors.New("trojan server password must not be empty")
} Prevention
- Check required credentials before config generation, not at runtime
- Substitute secrets via environment files and verify non-empty after rendering
When it happens
Trigger: A servers entry with no "password" key or "password": "" while building the Trojan outbound.
Common situations: Forgetting to fill in the password when templating configs, or the password living only in an env var that was not substituted before Xray read the file.
Related errors
- Trojan server address is not set.
- Invalid Trojan port.
- Trojan fallbacks: please fill in a valid value for every "de
- failed to get server spec
- not a Service.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/042b5b8863d354c7.
Report an issue: GitHub.