owasp-amass/amass · error
missing hostname in database URI
Error message
missing hostname in database URI
What it means
loadDatabase parsed the database URI but u.Hostname() returned empty: the URI has a scheme and username yet no host component (e.g. "postgres://user@/dbname"). The graph database server address is mandatory, so the guard rejects the URI before any connection is attempted.
Source
Thrown at config/graphdb.go:119
return nil
}
func (c *Config) loadDatabase(dbURI string) error {
u, err := url.Parse(dbURI)
if err != nil {
return err
}
// Check for valid scheme (database type)
if u.Scheme == "" {
return fmt.Errorf("missing scheme in database URI")
}
// Check for non-empty username
if u.User == nil || u.User.Username() == "" {
return fmt.Errorf("missing username in database URI")
}
// Check for reachable hostname
if u.Hostname() == "" {
return fmt.Errorf("missing hostname in database URI")
}
dbName := ""
// Only get the database name if it's not empty or a single slash
if u.Path != "" && u.Path != "/" {
dbName = strings.TrimPrefix(u.Path, "/")
}
db := &Database{
Primary: true, // Set as primary, because it wouldn't be there otherwise.
URL: dbURI,
System: u.Scheme,
Username: u.User.Username(),
DBName: dbName,
Host: u.Hostname(), // Hostname without port
Port: u.Port(), // Get port
}
View on GitHub (pinned to 79299dce87)
Solutions
- Add the host to the URI: neo4j://user:pass@localhost:7687/db.
- If using a socket/file-based DB, use the scheme/host syntax the driver actually supports instead of a bare path.
- Print the parsed URI parts (scheme, host, path) in a quick script to confirm what the config resolves to.
Example fix
// before "database": "neo4j://user:pass@/mydb" // after "database": "neo4j://user:pass@localhost:7687/mydb"
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(dbURI)
if u.Hostname() == "" {
return errors.New("database URI must include a hostname")
} Try / catch
if err := loadDatabase(uri); err != nil {
if strings.Contains(err.Error(), "missing hostname") {
return fmt.Errorf("check host portion of %q", uri)
}
} Prevention
- Template the host from a variable instead of hand-editing
- Validate URI host before saving config
- Avoid placeholder values like <host> reaching runtime
When it happens
Trigger: A configured URI missing the host, e.g. 'neo4j://user:pass@/db' or 'neo4j://user:pass@' reaching loadDatabase.
Common situations: Copy-paste mistakes that delete the host portion; a config template with a placeholder host that was never filled in; Unix-socket style URIs that this parser does not understand.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- missing scheme in database URI
- missing username in database URI
- unable to parse database URI query parameters: %v
- resolver entry %v is not a string
- brute forcing cannot be performed without DNS resolution
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/01f510c7f25e8186.
Report an issue: GitHub.