nsqio/nsq · error

failed to query any nsqlookupd: %s

Error message

failed to query any nsqlookupd: %s

What it means

ClusterInfo.GetLookupdTopics fans out HTTP requests to every nsqlookupd in parallel and merges topic lists. It only fails hard when the error count equals the number of addresses, i.e. every single nsqlookupd failed (dial errors, timeouts, non-2xx, or JSON decode failures); partial failures still return the merged topics plus an ErrList. This is the message nsqadmin shows when its --lookupd-http-address list is entirely unreachable.

Source

Thrown at internal/clusterinfo/data.go:108

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

			lock.Lock()
			defer lock.Unlock()
			topics = append(topics, resp.Topics...)
		}(addr)
	}
	wg.Wait()

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

	topics = stringy.Uniq(topics)
	sort.Strings(topics)

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

// GetLookupdTopicChannels returns a []string containing a union of all the channels
// from all the given lookupd for the given topic
func (c *ClusterInfo) GetLookupdTopicChannels(topic string, lookupdHTTPAddrs []string) ([]string, error) {
	var channels []string
	var lock sync.Mutex
	var wg sync.WaitGroup
	var errs []error

View on GitHub (pinned to 85cf10c09c)

Solutions

  1. Verify each address responds: curl http://<lookupd>:4161/topics
  2. Correct --lookupd-http-address entries (must be http addresses, e.g. 10.0.0.1:4161)
  3. Start or restart the nsqlookupd instances, then retry
  4. Check DNS resolution and firewall rules from the nsqadmin host

Example fix

# before
--lookupd-http-address=10.0.0.1:4160   # wrong port (this is TCP)

# after
--lookupd-http-address=10.0.0.1:4161
Defensive patterns

Strategy: retry

Validate before calling

// preflight each lookupd before the call
for _, a := range lookupdAddrs {
	resp, err := http.Get("http://" + a + "/topics")
	if err != nil || resp.StatusCode != 200 {
		log.Printf("lookupd %s unhealthy: %v", a, err)
	}
	if resp != nil {
		resp.Body.Close()
	}
}

Try / catch

var topics []string
var err error
for i := 0; i < 3; i++ {
	topics, err = ci.GetLookupdTopics(addrs)
	if err == nil {
		break
	}
	time.Sleep(time.Duration(i+1) * 500 * time.Millisecond)
}
if err != nil {
	return fmt.Errorf("all lookupd unreachable: %w", err)
}

Prevention

When it happens

Trigger: Calling GetLookupdTopics with addresses where no nsqlookupd is reachable: wrong host/port in --lookupd-http-address, lookupd processes down, firewall/DNS failure, or HTTPS-vs-HTTP scheme mismatch.

Common situations: nsqadmin deployed with a stale lookupd address after a cluster migration; lookupd restarted on a different port; network policy blocking the admin UI's egress; all replicas of nsqlookupd stopped for maintenance while someone opens the admin page.

Related errors


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