hashicorp/nomad · error

No service registrations with prefix %q found

Error message

No service registrations with prefix %q found

What it means

getServiceByPrefix resolves a user-supplied service name prefix across namespaces using Nomad's service registration list API. If no service registrations match the prefix in any namespace, the `nomad service info` command errors with `No service registrations with prefix %q found`. It indicates the service registry has no entries matching the query, not a transport failure.

Source

Thrown at command/service_info.go:298

		// ensuring the service name if the final argument on the command.
		if i == numArgs-1 {
			serviceName := newArgs[i]
			newArgs[i] = "-page-token=" + nextToken
			newArgs = append(newArgs, serviceName)
		}
	}
	return strings.Join(newArgs, " ")
}

func getServiceByPrefix(client *api.Services, opts *api.QueryOptions) (ns, id string, possible []*api.ServiceRegistrationListStub, err error) {
	possible, _, err = client.List(opts)
	if err != nil {
		return
	}

	switch len(possible) {
	case 0:
		err = fmt.Errorf("No service registrations with prefix %q found", opts.Prefix)
		return
	case 1: // single namespace
		ns = possible[0].Namespace
		services := possible[0].Services
		switch len(services) {
		case 0:
			// should never happen because we should never get an empty stub
			err = fmt.Errorf("No service registrations with prefix %q found", opts.Prefix)
			return
		case 1:
			id = services[0].ServiceName
			possible = nil
			return
		default:
			for _, service := range services {
				if service.ServiceName == opts.Prefix { // exact match
					id = service.ServiceName
					possible = nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run `nomad service list` (or list in all namespaces with -namespace '*') to see registered services and pick the exact name.
  2. Check the job that registers the service is running and uses a `service` block with the expected name/provider.
  3. Verify -namespace and ACL token capabilities for service registration read.
  4. Confirm you are querying Nomad service registry, not Consul, or use the right provider flag.

Example fix

// before
nomad service info web-frontend
// after
nomad service list
nomad service info -namespace default web
Defensive patterns

Strategy: validation

Validate before calling

// Check the service exists before fetching details
services, _, err := client.Services().List(nil)
if err != nil {
    return err
}
found := false
for _, ns := range services {
    for _, s := range ns.Services {
        if strings.HasPrefix(s.ServiceName, opts.Prefix) {
            found = true
        }
    }
}
if !found {
    return fmt.Errorf("no service registrations match %q; run 'nomad service list'", opts.Prefix)
}

Try / catch

// Distinguish not-found from transient errors when resolving the prefix
_, _, err := getServiceByPrefix(client, opts)
if err != nil {
    if strings.Contains(err.Error(), "No service registrations") {
        return fmt.Errorf("service %q not registered; check 'nomad service list' and the owning job", opts.Prefix)
    }
    return err // transport/ACL error
}

Prevention

When it happens

Trigger: Running `nomad service info <prefix>` where the prefix matches no registered services — the service was never registered, its job was stopped (deregistering services), wrong namespace, or a typo in the prefix.

Common situations: Querying before the job deploying the service has run; services deregistered after job stop; ACL token scoped to a namespace without the registrations; confusing Consul service names with Nomad-native service registrations; case-sensitivity mismatches.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/5401f671edda0795. Report an issue: GitHub.