nsqio/nsq · error

failed to query any nsqd: %s

Error message

failed to query any nsqd: %s

What it means

ClusterInfo.GetNSQDTopics queries the given nsqd nodes directly (their /stats endpoint topic section), unioning topic names. It fails with this message only when every nsqd request errored; partial failures return the union plus an ErrList. nsqadmin hits this path when run with --nsqd-http-address instead of --lookupd-http-address.

Source

Thrown at internal/clusterinfo/data.go:331

			err := c.client.GETV1(endpoint, &resp)
			if err != nil {
				lock.Lock()
				errs = append(errs, err)
				lock.Unlock()
				return
			}

			lock.Lock()
			defer lock.Unlock()
			for _, topic := range resp.Topics {
				topics = stringy.Add(topics, topic.Name)
			}
		}(addr)
	}
	wg.Wait()

	if len(errs) == len(nsqdHTTPAddrs) {
		return nil, fmt.Errorf("failed to query any nsqd: %s", ErrList(errs))
	}

	sort.Strings(topics)

	if len(errs) > 0 {
		return topics, ErrList(errs)
	}
	return topics, nil
}

// GetNSQDProducers returns Producers of all the given nsqd
func (c *ClusterInfo) GetNSQDProducers(nsqdHTTPAddrs []string) (Producers, error) {
	var producers Producers
	var lock sync.Mutex
	var wg sync.WaitGroup
	var errs []error

	type infoRespType struct {

View on GitHub (pinned to 85cf10c09c)

Solutions

  1. Test one node: curl http://<nsqd>:4151/stats
  2. Use the HTTP port 4151 in --nsqd-http-address (not 4150)
  3. Restart nsqd or fix its --http-address binding if it listens elsewhere
  4. Prefer --lookupd-http-address for dynamic clusters so the list stays current

Example fix

# before
--nsqd-http-address=10.0.0.1:4150   # TCP port, wrong

# after
--nsqd-http-address=10.0.0.1:4151
Defensive patterns

Strategy: retry

Validate before calling

for _, a := range nsqdAddrs {
	resp, err := http.Get("http://" + a + "/stats")
	if err != nil { log.Printf("nsqd %s down", a); continue }
	resp.Body.Close()
}

Try / catch

topics, err := ci.GetNSQDTopics(addrs)
if err != nil && strings.Contains(err.Error(), "failed to query any nsqd") {
	// all direct nsqd queries failed: check ports/health, then retry with backoff
}

Prevention

When it happens

Trigger: Every address in --nsqd-http-address failing: nsqd processes down, wrong host/port (HTTP port is 4151, not the TCP 4150), firewall blocks, or invalid addresses that fail before the request.

Common situations: Confusing the TCP (4150) and HTTP (4151) nsqd ports in the flag; pointing nsqadmin at a dead node list; container network segmentation blocking the admin UI from nsqd; all nsqd restarted on different ports.

Related errors


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