How to fix nslookup: can't resolve 'myservice' in Kubernetes
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>- Verify service exists
- Verify service has endpoints
- Check pod labels match service selector
- Ensure pods are running
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
- 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
- Pods are not running or not ready
- CoreDNS not running or not configured
- Network policies blocking DNS or traffic
- Typo in service name
How to fix "nslookup: can't resolve 'myservice'"
List services:
kubectl get svc -n <namespace>
kubectl describe svc <service-name> -n <namespace>Check for spelling and namespace.
Service needs running pods matching its selector:
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.
Compare labels:
kubectl get pods --show-labels -n <namespace>
kubectl describe svc <service-name> -n <namespace> | grep SelectorPod labels must match service selector exactly (case-sensitive).
Check pod status:
kubectl get pods -n <namespace>Pods must be Running and Ready. Fix startup issues if pods are not running.
Use fully qualified domain name:
# From pod in different namespace
curl http://myservice.other-namespace.svc.cluster.local:8080Within same namespace, just myservice works.
From a pod, test DNS:
kubectl exec -it <pod-name> -n <namespace> -- nslookup myserviceIf resolution fails, check CoreDNS.
Check DNS add-on:
kubectl get pods -n kube-system | grep corednsIf 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
- 📚Kubernetes Official Documentation
- 📖K8s: Services(Official Docs)
- 🐙K8s GitHub Issues(GitHub)
- 💬SO: K8s Services(Stack Overflow)