router-for-me/CLIProxyAPI · error

home: invalid address (host=%q port=%d)

Error message

home: invalid address (host=%q port=%d)

What it means

Returned by ensureClients in internal/home/client.go when addrLocked() fails: the home host is empty/whitespace or the port is <= 0. The message prints the offending host and port so you can see exactly which field is bad. The client needs a valid host:port before it can construct the Redis command/pubsub clients.

Source

Thrown at internal/home/client.go:494

	if c == nil {
		return ErrDisabled
	}
	if c.dispatchFenced.Load() {
		return ErrDispatchFenced
	}
	if !c.Enabled() {
		return ErrDisabled
	}
	c.waitForClientsClosed()
	c.mu.Lock()
	defer c.mu.Unlock()
	if c.dispatchFenced.Load() {
		return ErrDispatchFenced
	}

	addr, ok := c.addrLocked()
	if !ok {
		return fmt.Errorf("home: invalid address (host=%q port=%d)", c.homeCfg.Host, c.homeCfg.Port)
	}

	if c.cmd == nil {
		options, errOptions := c.redisOptionsLocked(addr)
		if errOptions != nil {
			return errOptions
		}
		c.cmdOptions = cloneRedisOptions(options)
		c.cmd = redis.NewClient(options)
	}
	if c.sub == nil {
		options, errOptions := c.redisOptionsLocked(addr)
		if errOptions != nil {
			return errOptions
		}
		c.sub = redis.NewClient(options)
	}
	return nil

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Set a non-empty host and a positive integer port in the home config block
  2. Verify env vars are actually exported / .env is in the process working directory
  3. Check the config hot-reload watcher picked up the corrected file if running

Example fix

# before
home:
  enabled: true

# after
home:
  enabled: true
  host: home.internal
  port: 6379
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(cfg.Home.Host) == "" || cfg.Home.Port <= 0 || cfg.Home.Port > 65535 {
    return fmt.Errorf("home requires a valid host and 1-65535 port (got host=%q port=%d)", cfg.Home.Host, cfg.Home.Port)
}

Prevention

When it happens

Trigger: Home enabled in config but host empty or port 0/unset (port field omitted so Go zero value 0 is used); host set only via env var that is not loaded; whitespace-pasted host; port parsed from a string that failed to unmarshal.

Common situations: Config yaml enables home but misses the address block; .env not in the working directory so HOME_HOST/HOME_PORT never load; port specified as a string ('6379') against an int field causing silent zero on some unmarshalers; staging config copied without the address section.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/fafbab10ac77a550. Report an issue: GitHub.