hashicorp/nomad · warning

service registration not found

Error message

service registration not found

What it means

deleteServiceRegistrationByIDTxn deletes a service registration by its (namespace, service ID) pair. The unique-index lookup returning nil produces "service registration not found", aborting the delete. Registrations are ephemeral (tied to node heartbeats), so they can vanish without any explicit delete.

Source

Thrown at nomad/state/state_store_service_registration.go:108

	defer txn.Abort()

	if err := s.deleteServiceRegistrationByIDTxn(index, txn, namespace, id); err != nil {
		return err
	}
	return txn.Commit()
}

func (s *StateStore) deleteServiceRegistrationByIDTxn(
	index uint64, txn *txn, namespace, id string) error {

	// Lookup the service registration by its ID and namespace. This is a
	// unique index and therefore there will be a maximum of one entry.
	existing, err := txn.First(TableServiceRegistrations, indexID, namespace, id)
	if err != nil {
		return fmt.Errorf("service registration lookup failed: %v", err)
	}
	if existing == nil {
		return errors.New("service registration not found")
	}

	// Delete the existing entry from the table.
	if err := txn.Delete(TableServiceRegistrations, existing); err != nil {
		return fmt.Errorf("service registration deletion failed: %v", err)
	}

	// Update the index table to indicate an update has occurred.
	if err := txn.Insert(tableIndex, &IndexEntry{TableServiceRegistrations, index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	return nil
}

// DeleteServiceRegistrationByNodeID deletes all service registrations that
// belong on a single node. If there are no registrations tied to the nodeID,
// the call will noop without an error.
func (s *StateStore) DeleteServiceRegistrationByNodeID(

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. List current registrations (nomad service info <service>) to confirm the exact namespace and ID.
  2. Pass the correct -namespace flag matching where the service was registered.
  3. Treat not-found as success in cleanup automation since the target state already holds.
  4. Re-register the service if it should exist and the delete was a mistake.

Example fix

// before
client.Services().DeleteByID(ns, serviceID, nil)
// after: tolerate GC'd registrations
err := client.Services().DeleteByID(ns, serviceID, nil)
if err != nil && strings.Contains(err.Error(), "not found") {
    return nil // already gone (node GC)
}
Defensive patterns

Strategy: fallback

Validate before calling

// confirm the registration still exists
services, _, err := client.Services().Get(ns, serviceName, nil)
if err != nil || len(services) == 0 {
    return nil // nothing registered / already GC'd
}

Try / catch

err := client.Services().DeleteByID(ns, serviceID, nil)
if err != nil && strings.Contains(err.Error(), "not found") {
    return nil // node GC removed it already
}

Prevention

When it happens

Trigger: ServiceRegistration.Delete RPC (nomad service delete or services delete API) for a namespace+ID that is no longer registered; the service deregistered automatically when its node was garbage-collected; duplicate concurrent deletes.

Common situations: Cleanup scripts running after Nomad already GC'd the registration via node expiry; deleting with the wrong namespace (e.g., default vs a dedicated one); typos in the ID argument.

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/a3e9d362a5884e42. Report an issue: GitHub.