owasp-amass/amass · error

missing hostname in database URI

Error message

missing hostname in database URI

What it means

loadEngineURI parsed the engine API URI but u.Hostname() is empty — the URI has a scheme yet no host (e.g. "grpc:///path" or a malformed authority section). Without a hostname the API endpoint cannot be reached, so the guard rejects it. Also exercised by TestLoadEngineEnvSettings_MissingEnvSettings when AMASS_ENGINE_HOST is unset.

Source

Thrown at config/engineapi.go:123

	return nil
}

// loadEngineURI takes the Engine API's URI as a string, parses it, and populates the EngAPI structure with the URI's components.
// It performs validations to ensure the URI contains a valid scheme and hostname. If parsing fails or any validation check doesn't pass,
// an error is returned. It also handles extracting authentication information and any additional options provided in the URI query.
func (c *Config) loadEngineURI(apiURI string) error {
	// Parse the raw URI string to a url.URL object. If the URI is malformed, an error is returned.
	u, err := url.Parse(apiURI)
	if err != nil {
		return err
	}
	// Check for valid scheme
	if u.Scheme == "" {
		return fmt.Errorf("missing scheme in database URI")
	}
	// Check for reachable hostname
	if u.Hostname() == "" {
		return fmt.Errorf("missing hostname in database URI")
	}
	// If the path is present in the URI and is more than just a "/", it's trimmed and used.
	// If the path is empty or just a "/", it defaults to an empty string.
	apiURIPath := ""
	// Only get the api file path name if it's not empty or a single slash
	if u.Path != "" && u.Path != "/" {
		apiURIPath = strings.TrimPrefix(u.Path, "/")
	}
	// Initialize a new EngAPI object with data from the parsed URI.
	api := &EngAPI{
		URL:      apiURI,
		Scheme:   u.Scheme,
		Username: u.User.Username(),
		Path:     apiURIPath,
		Host:     u.Hostname(), // Hostname without port
		Port:     u.Port(),     // Get port
	}
	// If a password is set in the URI, it's extracted and stored in the EngAPI object.

View on GitHub (pinned to 79299dce87)

Solutions

  1. Include the host in the engine URI, e.g. "grpc://127.0.0.1:2301"
  2. Set AMASS_ENGINE_HOST (and port) when configuring via environment variables
  3. Check for empty url.URL.Hostname() before accepting user- or env-provided URIs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at config/engineapi.go:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/9c35dd86ae8709ec. Report an issue: GitHub.