XTLS/Xray-core · error
invalid host + host
Error message
invalid host + host
What it means
Thrown by Realm.Build() when the parsed Realm URL has an empty host component. After scheme validation, u.Hostname() must yield a non-empty value; a URL like 'realm:///path' (no authority) fails here. The host is a required part of the Realm endpoint address.
Source
Thrown at infra/conf/transport_finalmask.go:845
var tlsConfig *tls.Config
u, err := url.Parse(c.Url)
if err != nil {
return nil, err
}
switch u.Scheme {
case "realm":
scheme = "https"
case "realm+http":
scheme = "http"
default:
return nil, errors.New("invalid scheme", u.Scheme)
}
host = u.Hostname()
if host == "" {
return nil, errors.New("invalid host", host)
}
port = u.Port()
if port == "" {
port = "443"
if scheme == "http" {
port = "80"
}
}
token, err = url.PathUnescape(u.User.String())
if err != nil {
return nil, err
}
if token == "" {
return nil, errors.New("invalid token", token)
}
View on GitHub (pinned to 7d214f8b09)
Solutions
- Include an explicit host: 'realm://token@host:port/id'.
- Log or echo the final URL string before running the core to catch empty substitutions.
- Validate the URL with net/url in a pre-flight check (see defense).
Example fix
// before "url": "realm://mytoken@/v1" // after "url": "realm://mytoken@signal.example.com:8443/v1"
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(raw)
if u.Hostname() == "" {
return fmt.Errorf("realm url is missing a host")
} Prevention
- Assert non-empty hostname after env-var/template substitution.
- Build Realm URLs from parts (scheme, userinfo, host, port, path) instead of string concatenation.
- Lint config files for 'realm:///' patterns missing the authority.
When it happens
Trigger: Passing 'realm:///id' (missing authority), a URL whose host is only userinfo ('realm://token@/id'), or a value that lost its host during string concatenation/template interpolation.
Common situations: Environment-variable substitution producing an empty host; hand-built URL strings with a double '//' after the scheme; copying a share link and deleting the hostname.
Related errors
- invalid scheme + u.Scheme
- invalid token + token
- invalid id + id
- bridge tag is empty
- bridge domain is empty
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/b44e47b2d32cfbef.
Report an issue: GitHub.