grpc/grpc-go · error
missing address
Error message
missing address
What it means
Returned by parseTarget (in the delegating resolver) when the target string is the empty string. This is the inner cause surfaced for dns targets with no host. It indicates the endpoint portion of the target URI was empty, so there is nothing to resolve.
Source
Thrown at internal/resolver/delegatingresolver/delegatingresolver.go:231
}
return false
}
// parseTarget takes a target string and ensures it is a valid "host:port" target.
//
// It does the following:
// 1. If the target already has a port (e.g., "host:port", "[ipv6]:port"),
// it is returned as is.
// 2. If the host part is empty (e.g., ":80"), it defaults to "localhost",
// returning "localhost:80".
// 3. If the target is missing a port (e.g., "host", "ipv6"), the defaultPort
// is added.
//
// An error is returned for empty targets or targets with a trailing colon
// but no port (e.g., "host:").
func parseTarget(target string) (string, error) {
if target == "" {
return "", fmt.Errorf("missing address")
}
host, port, err := net.SplitHostPort(target)
if err != nil {
// If SplitHostPort fails, it's likely because the port is missing.
// We append the default port and return the result.
return net.JoinHostPort(target, defaultPort), nil
}
// If SplitHostPort succeeds, we check for edge cases.
if port == "" {
// A success with an empty port means the target had a trailing colon,
// e.g., "host:", which is an error.
return "", fmt.Errorf("missing port after port-separator colon")
}
if host == "" {
// A success with an empty host means the target was like ":80".
// We default the host to "localhost".View on GitHub (pinned to 03255a9237)
Solutions
- Provide a non-empty host/port in the dial target.
- Validate that the address is non-empty at the config boundary before dialing.
- Fail fast at startup if the resolved target string is empty rather than dialing.
Example fix
// before
target := os.Getenv("SVC_ADDR") // unset -> ""
conn, _ := grpc.Dial(target, ...)
// after
target := os.Getenv("SVC_ADDR")
if target == "" { log.Fatal("SVC_ADDR required") }
conn, _ := grpc.Dial(target, ...) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(target) == "" {
return errors.New("dial target is empty")
} Try / catch
if target == "" {
return errors.New("cannot dial empty target")
}
conn, err := grpc.Dial(target, ...) Prevention
- Validate non-empty target at the configuration boundary.
- Refuse to start if service discovery returns an empty address.
- Add a startup assertion for required address env vars.
When it happens
Trigger: Dialing with an empty or whitespace target such as "", "dns:///", or a target built from an unset config value. parseTarget is also used internally by the dns resolver for its authority.
Common situations: Service discovery config that returns an empty address; dial target assembled from an unset environment variable; blank value passed through a flag default.
Related errors
- missing port after port-separator colon
- delegating_resolver: invalid target address %q: %v
- invalid target address %v, error info: %v
- delegating_resolver: failed to determine proxy URL for targe
- delegating_resolver: unable to build the resolver for target
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/1e60d8d2c2af1434.
Report an issue: GitHub.