micro/go-micro · error · ErrNotFound
service not found
Error message
service not found
What it means
registry.ErrNotFound is the sentinel error returned by GetService (and lookups like next/serviceWithName/Load) when no service with the requested name exists in the registry. It is the library's contract for 'unknown service name'.
Source
Thrown at registry/registry.go:10
// Package registry is an interface for service discovery
package registry
import (
"errors"
)
var (
// Not found error when GetService is called.
ErrNotFound = errors.New("service not found")
// Watcher stopped error when watcher is stopped.
ErrWatcherStopped = errors.New("watcher stopped")
)
// The registry provides an interface for service discovery
// and an abstraction over varying implementations
// {consul, etcd, zookeeper, ...}.
type Registry interface {
Init(...Option) error
Options() Options
Register(*Service, ...RegisterOption) error
Deregister(*Service, ...DeregisterOption) error
GetService(string, ...GetOption) ([]*Service, error)
ListServices(...ListOption) ([]*Service, error)
Watch(...WatchOption) (Watcher, error)
String() string
}
View on GitHub (pinned to 24529f1404)
Solutions
- Verify the exact service name matches what the server registered (check name, version, namespace)
- Compare with errors.Equal/== against registry.ErrNotFound and implement retry-with-backoff until the service appears
- Check the target service is running and successfully registered (inspect registry contents directly)
- Increase or verify TTL refresh/heartbeats so registrations don't expire
Example fix
// before
svc, err := registry.GetService("grettr") // typo, err not checked against sentinel
// after
if err == registry.ErrNotFound {
time.Sleep(500 * time.Millisecond) // backoff and retry
svc, err = registry.GetService("greeter")
} Defensive patterns
Strategy: retry
Validate before calling
_, err := reg.GetService(name)
if err == registry.ErrNotFound {
// service absent; wait or check registration before proceeding
} Type guard
func isNotFound(err error) bool {
return errors.Is(err, registry.ErrNotFound)
} Try / catch
svc, err := reg.GetService("greeter")
if errors.Is(err, registry.ErrNotFound) {
// retry with backoff or surface 'unknown service' to caller
} Prevention
- Verify exact service name spelling and namespace at both ends
- Use retry with backoff to handle registration startup races
- Monitor service TTL renewal so registrations don't expire
When it happens
Trigger: Calling registry.GetService("name") for a service never registered; calling after the service deregistered or its TTL/lease expired; registry cache missing the entry (e.g. cache not yet populated); tests calling Read/Load for a missing fixture service.
Common situations: Typo in the service name or mismatched namespace/environment prefixes; client started before the target service registered (startup race); etcd/consul entries evicted due to TTL expiry or network partition; switching registries between environments.
Related errors
- not found
- failed to discover services: %w
- failed to register service
- agent: checkpointed run not found
- no registry configured
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/37e5c28e7e5952bc.
Report an issue: GitHub.