nsqio/nsq · error

address should not contain scheme

Error message

address should not contain scheme

What it means

nsq_stat validates the addresses passed to --nsqd-http-address (and --lookupd-http-address) via checkAddrs and rejects any value with an 'http' prefix. The tool builds the HTTP URL itself from a bare host:port, so a scheme in the input would produce a malformed URL like http://http://host:port. On failure main() exits immediately with log.Fatalf.

Source

Thrown at apps/nsq_stat/nsq_stat.go:126

			c.MemoryDepth,
			c.BackendDepth,
			c.InFlightCount,
			c.DeferredCount,
			c.RequeueCount,
			c.TimeoutCount,
			c.MessageCount,
			c.ClientCount)

		o = c
		time.Sleep(interval)
	}
	os.Exit(0)
}

func checkAddrs(addrs []string) error {
	for _, a := range addrs {
		if strings.HasPrefix(a, "http") {
			return errors.New("address should not contain scheme")
		}
	}
	return nil
}

func main() {
	flag.Parse()

	if *showVersion {
		fmt.Printf("nsq_stat v%s\n", version.Binary)
		return
	}

	if *topic == "" || *channel == "" {
		log.Fatal("--topic and --channel are required")
	}

	intvl := *interval

View on GitHub (pinned to 85cf10c09c)

Solutions

  1. Remove the scheme: use --nsqd-http-address=127.0.0.1:4151 (host:port only).
  2. If several addresses are given, strip http:// or https:// from every one; checkAddrs fails on the first match it finds.
  3. If a reverse proxy or TLS terminator fronts nsqd, point nsq_stat at the plain host:port it can reach, or fix the proxy config rather than adding a scheme.

Example fix

# before
nsq_stat --nsqd-http-address=http://127.0.0.1:4151 --topic=test --interval=5s
# after
nsq_stat --nsqd-http-address=127.0.0.1:4151 --topic=test --interval=5s
Defensive patterns

Strategy: validation

Validate before calling

func normalizeAddr(a string) string {
	for _, p := range []string{"https://", "http://"} {
		a = strings.TrimPrefix(strings.TrimSpace(a), p)
	}
	return strings.TrimSuffix(a, "/")
}

for i, a := range nsqdHTTPAddrs {
	nsqdHTTPAddrs[i] = normalizeAddr(a) // pass host:port to --nsqd-http-address
}

Prevention

When it happens

Trigger: Running apps/nsq_stat with a flag value such as --nsqd-http-address=http://127.0.0.1:4151 or --lookupd-http-address=https://lookup:4161. strings.HasPrefix(a, "http") matches both http and https prefixes, and only the first offending address is reported before the process dies.

Common situations: Copy-pasting a health-check or browser URL into the flag; migrating scripts that used curl http://...; wrapping nsq_stat in tooling that normalizes addresses as URLs. Users coming from nsqadmin docs where URLs appear frequently.

Related errors


AI-assisted analysis of nsqio/nsq@85cf10c09c (2026-08-16). Data as JSON: /api/errors/875ed3960458fe8b. Report an issue: GitHub.