How to fix nslookup: can't resolve 'myservice' in Kubernetes

KubernetesBEGINNERMEDIUMUpdated Dec 6, 2025· 105 views

A pod cannot reach a Kubernetes Service because the Service doesn't exist, is in a different namespace, or has no endpoints. Applications can't connect to the service DNS name. Fix by creating the Service, verifying label selectors match pod labels, or using fully qualified DNS names for cross-namespace access.

Quick fix

Fixes nslookup: can't resolve 'myservice'

kubectl get svc -n <namespace>
kubectl describe svc <service-name> -n <namespace>
  1. Verify service exists
  2. Verify service has endpoints
  3. Check pod labels match service selector
  4. Ensure pods are running
kubernetes — error
kubectl get svc -n <namespace>
kubectl describe svc <service-name> -n <namespace>
nslookup: can't resolve 'myservice'

What this error means

Kubernetes Services provide stable DNS names for pod groups. When a pod tries to reach a service by name (e.g., myservice or myservice:8080), Kubernetes DNS (CoreDNS) resolves the name to the service's cluster IP. If the Service doesn't exist, the DNS lookup fails. Alternatively, the Service may exist but have no endpoints (no running pods match its label selector), so even if DNS resolves, traffic fails. Services are namespace-scoped; cross-namespace access requires fully qualified names.

Typical symptoms

  • Connection timeout or "name not found" when connecting to service
  • DNS lookup fails for service name
  • kubectl describe service shows no endpoints
  • Ingress controller reports "service not found"
  • Some pods can reach service, others cannot (namespace mismatch)
  • Service exists but traffic doesn't reach pods

Common causes

  1. Service doesn't exist or wrong name
  2. Service in different namespace (no cross-namespace access by default)
  3. Label selector doesn't match any pod labels
  4. Pods are not running or not ready
  5. CoreDNS not running or not configured
  6. Network policies blocking DNS or traffic
  7. Typo in service name

How to fix "nslookup: can't resolve 'myservice'"

1Verify service exists

List services:

bash
kubectl get svc -n <namespace>
kubectl describe svc <service-name> -n <namespace>

Check for spelling and namespace.

2Verify service has endpoints

Service needs running pods matching its selector:

bash
kubectl describe svc <service-name> -n <namespace>
# Look at Endpoints field

kubectl get endpoints <service-name> -n <namespace>

If Endpoints shows <none>, no pods match selector.

3Check pod labels match service selector

Compare labels:

bash
kubectl get pods --show-labels -n <namespace>
kubectl describe svc <service-name> -n <namespace> | grep Selector

Pod labels must match service selector exactly (case-sensitive).

4Ensure pods are running

Check pod status:

bash
kubectl get pods -n <namespace>

Pods must be Running and Ready. Fix startup issues if pods are not running.

5For cross-namespace access, use FQDN

Use fully qualified domain name:

bash
# From pod in different namespace
curl http://myservice.other-namespace.svc.cluster.local:8080

Within same namespace, just myservice works.

6Test DNS resolution

From a pod, test DNS:

bash
kubectl exec -it <pod-name> -n <namespace> -- nslookup myservice

If resolution fails, check CoreDNS.

7Verify CoreDNS is running

Check DNS add-on:

bash
kubectl get pods -n kube-system | grep coredns

If missing or not running, cluster DNS won't work.

Advanced notes

Services don't require explicit export for cross-namespace access—just use FQDN. Network policies can block DNS (UDP/53) or traffic to service ports. Use "publishNotReadyAddresses: true" if pods should be endpoints while starting. For Ingress, ensure backend service exists in same namespace as Ingress resource. Services with no endpoints still exist; traffic just fails (useful for external services pointing to non-Kubernetes endpoints).

Frequently asked questions

What does "nslookup: can't resolve 'myservice'" mean?
Kubernetes Services provide stable DNS names for pod groups. , myservice or myservice:8080), Kubernetes DNS (CoreDNS) resolves the name to the service's cluster IP. If the Service doesn't exist, the DNS lookup fails.
How do I fix "nslookup: can't resolve 'myservice'"?
A pod cannot reach a Kubernetes Service because the Service doesn't exist, is in a different namespace, or has no endpoints. Applications can't connect to the service DNS name. Fix by creating the Service, verifying label selectors match pod labels, or using fully qualified DNS names for cross-namespace access.
What causes "nslookup: can't resolve 'myservice'"?
Service doesn't exist or wrong name Service in different namespace (no cross-namespace access by default) Label selector doesn't match any pod labels
Is the "nslookup: can't resolve 'myservice'" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading