What "no endpoints" means
A Kubernetes Service has no endpoints when no Ready pod matches its selector on a port the Service can resolve. Clients get Connection refused straight away, and an ingress in front of it returns 503. There are five causes: the selector matches no pods, the pods match but fail their readiness probe, the Service's named targetPort does not exist on the container, the workload is scaled to zero, or the Service has no selector and nobody maintains its EndpointSlices. Run kubectl get endpointslices -l kubernetes.io/service-name=NAME and compare it with the pods the selector returns.
A sixth case looks the same from the client but is a different problem: endpoints exist, and the connection is still refused. That is a wrong numeric targetPort or an application listening on 127.0.0.1. Step 1 tells the two apart in one command, which matters because the fixes live in different files.
Step 1: Refused or timed out, and are there endpoints?
Reproduce from inside the cluster, in the same namespace as the caller:
kubectl -n shop run tmp --rm -it --restart=Never --image=curlimages/curl -- \
curl -sv --max-time 5 http://checkout.shop.svc.cluster.local/healthz
* Trying 172.20.118.4:80...
* connect to 172.20.118.4 port 80 failed: Connection refused
curl: (7) Failed to connect to checkout.shop.svc.cluster.local port 80: Connection refused
The error class already narrows it down:
| Client sees | Meaning | Go to |
|---|---|---|
Could not resolve host | DNS, not the Service. Wrong name or namespace | The CoreDNS guide |
Connection refused, instantly | No endpoints, or the pod refused the port | Steps 2 to 5 |
| Timeout after 5 seconds | Packets dropped: NetworkPolicy, security group, dead pod IP | Step 6 |
| 503 from ingress-nginx | The ingress controller sees zero endpoints | Steps 2 to 4 |
The instant refusal is deliberate. When a Service has zero endpoints, kube-proxy in iptables mode installs a reject rule for the ClusterIP, which you can see on any node:
sudo iptables-save | grep 'has no endpoints'
-A KUBE-SERVICES -d 172.20.118.4/32 -p tcp -m comment --comment "shop/checkout:http has no endpoints" -m tcp --dport 80 -j REJECT --reject-with icmp-port-unreachable
Now look at what the Service is backed by:
kubectl -n shop get svc checkout -o wide
kubectl -n shop get endpointslices -l kubernetes.io/service-name=checkout
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
checkout ClusterIP 172.20.118.4 <none> 80/TCP 41d app=checkout,tier=api
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
checkout-x7k2p IPv4 <unset> <unset> 41d
<unset> under ENDPOINTS means the controller found nothing to put there. Use EndpointSlices, not kubectl get endpoints: the v1 Endpoints API is deprecated since Kubernetes 1.33 and kubectl prints a warning when you read it. One trap: the EndpointSlice table lists addresses of pods that are not Ready too, so an IP in that column does not prove traffic can flow. Print the readiness condition explicitly:
kubectl -n shop get endpointslices -l kubernetes.io/service-name=checkout \
-o jsonpath='{range .items[*].endpoints[*]}{.addresses[0]}{"\t"}ready={.conditions.ready}{"\t"}{.targetRef.name}{"\n"}{end}'
10.0.41.23 ready=false checkout-6c9f7d5b8-kq2vz
10.0.52.118 ready=false checkout-6c9f7d5b8-w8tnl
No lines at all: the selector matches nothing (Step 2) or there are no pods (Step 4). Lines with ready=false: Step 3. Lines with ready=true and the client is still refused: Step 5.
Step 2: The selector matches no pods
Ask the API server for exactly the pods the Service selects. This builds the label query from the live Service so you cannot mistype it:
SEL=$(kubectl -n shop get svc checkout -o json \
| jq -r '.spec.selector | to_entries | map("\(.key)=\(.value)") | join(",")')
echo "$SEL"
kubectl -n shop get pods -l "$SEL" -o wide
kubectl -n shop get pods --show-labels
app=checkout,tier=api
No resources found in shop namespace.
NAME READY STATUS RESTARTS AGE LABELS
checkout-6c9f7d5b8-kq2vz 1/1 Running 0 3h app=checkout,pod-template-hash=6c9f7d5b8,tier=backend
The pods carry tier=backend; the Service asks for tier=api. A selector is an AND across every key, so one stale label empties the Service. The usual ways this happens:
- A label was renamed in the Deployment and not in the Service. Deployment selectors are immutable, so someone recreated the Deployment with new labels and the Service kept the old ones.
- Helm release name drift. Charts select on
app.kubernetes.io/instance. Install the same chart ascheckout-v2and a hand-written Service still selectinginstance: checkoutmatches nothing. - Wrong namespace. A selector only sees pods in the Service's own namespace. A Service in
defaultcannot select pods inshop, whatever the labels say. - Kustomize
commonLabelsapplied to one side only, because the Service and Deployment live in different bases.
Fix the Service, since its selector is mutable and the Deployment's is not:
kubectl -n shop patch svc checkout --type merge \
-p '{"spec":{"selector":{"app":"checkout","tier":"backend"}}}'
Then make the same change in Git, or the next sync puts the broken selector back. The opposite mistake is as bad and much quieter: a selector that is too broad, such as app=checkout alone, also matches the checkout-worker pods, and a third of requests get refused by pods that never listened on that port.
Step 3: Pods match but are not Ready
Only pods whose Ready condition is true receive Service traffic. Check the pods the selector returned:
kubectl -n shop get pods -l "$SEL" -o wide
kubectl -n shop describe pod checkout-6c9f7d5b8-kq2vz | sed -n '/Conditions:/,/Volumes:/p;/Events:/,$p'
NAME READY STATUS RESTARTS AGE IP NODE READINESS GATES
checkout-6c9f7d5b8-kq2vz 0/1 Running 0 3h 10.0.41.23 ip-10-0-41-17 <none>
Conditions:
Type Status
Ready False
ContainersReady False
Events:
Warning Unhealthy 2m (x412 over 3h) kubelet Readiness probe failed: HTTP probe failed with statuscode: 503
Running with 0/1 is the signature. Three patterns account for nearly all of it:
- The probe checks a dependency. If
/readyreturns 503 whenever Postgres or a downstream API is slow, every replica goes unready in the same second and the Service empties. A readiness probe should answer one question, whether this process can accept a request, and leave shared dependencies out. The probes guide covers how to split that from liveness. - The probe points at the wrong port or path. It returns 404 or connection refused from the first second. Compare the probe's
portandpathwith what the app serves. - A readiness gate never turns true. If the READINESS GATES column shows
0/1, the containers are fine but an external controller (the AWS Load Balancer Controller registering the pod in a target group, for example) has not set its condition. Look at that controller's logs, not the pod's.
If the pods are restarting and not merely unready, the Service is a bystander; work through the CrashLoopBackOff guide first.
For StatefulSet peers that must find each other before they are Ready (database clusters, Kafka), set publishNotReadyAddresses: true on the headless Service. Do not use it on a client-facing Service to make the symptom go away.
Step 4: No pods, or a Service without a selector
kubectl -n shop get deploy,hpa,scaledobject 2>/dev/null
0/0 under READY means someone or something scaled the workload to zero: a KEDA ScaledObject with minReplicaCount: 0 and no trigger firing, or a nightly scale-down job like the one in the idle cost post. With KEDA that is working as designed, but plain Services do not hold requests while pods start; you need the KEDA HTTP add-on or a queue in front for that.
If kubectl get svc -o wide shows <none> under SELECTOR, Kubernetes never manages the endpoints. A hand-written EndpointSlice must satisfy three rules, and breaking any of them leaves the Service empty with no error:
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: legacy-db-1
namespace: shop
labels:
kubernetes.io/service-name: legacy-db # 1. must equal the Service name
addressType: IPv4
ports:
- name: postgres # 2. must equal the Service port's name
port: 5432
protocol: TCP
endpoints:
- addresses: ["10.20.3.14"] # 3. must not be a ClusterIP or loopback
conditions:
ready: true
Step 5: Endpoints exist, connection still refused
Here the Service is wired to pods and the pod itself refuses the connection. Compare three numbers: the Service targetPort, the container's declared port, and the port the process really listens on.
kubectl -n shop get svc checkout -o jsonpath='{range .spec.ports[*]}{.name}{"\t"}port={.port}{"\t"}targetPort={.targetPort}{"\n"}{end}'
kubectl -n shop get pod checkout-6c9f7d5b8-kq2vz \
-o jsonpath='{range .spec.containers[*].ports[*]}{.name}{"\t"}{.containerPort}{"\n"}{end}'
kubectl -n shop debug -it checkout-6c9f7d5b8-kq2vz --image=nicolaka/netshoot \
--target=checkout -- ss -ltn
http port=80 targetPort=8080
web 3000
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 511 127.0.0.1:3000 0.0.0.0:*
This output contains two separate bugs:
- Wrong numeric targetPort. The Service forwards to 8080 and nothing listens there. A numeric
targetPortis never validated against the pod spec, so the EndpointSlice happily advertises10.0.41.23:8080. SettargetPort: 3000, or better,targetPort: web, so the Service follows the container's named port when the number changes. - Loopback bind. The process listens on
127.0.0.1:3000, which is reachable only from inside the pod's network namespace. It must bind0.0.0.0(or::). Dev servers do this by default: Vite,flask run,uvicornwithout--host 0.0.0.0, and Node apps passinglocalhosttolisten().
A named targetPort fails differently. If the Service says targetPort: http and no container port carries that name, the controller cannot resolve it and the pod is published without a usable port, which puts you back in the "no endpoints" case even though every pod is Ready. Port names are case-sensitive.
Two tests mislead people here. kubectl port-forward connects to localhost inside the pod, so it works against an app bound to 127.0.0.1 and "proves" the app is fine. And an exec readiness probe that curls localhost passes for the same reason. Test the way the Service does, against the pod IP:
kubectl -n shop run tmp --rm -it --restart=Never --image=curlimages/curl -- \
curl -sv --max-time 5 http://10.0.41.23:3000/healthz
Pod IP works and the Service does not: the bug is in the Service spec. Pod IP is refused: the bug is in the application.
Step 6: It times out instead
A timeout with Ready endpoints means packets are being dropped, not rejected. Check for a default-deny policy in the destination namespace:
kubectl -n shop get networkpolicy
kubectl -n shop describe networkpolicy default-deny-ingress
If ingress is denied by default, the caller's namespace and pod labels need an explicit allow rule on the target port (the pod's port, 3000, not the Service port 80). Generating those rules from observed traffic is the subject of the network policy agent post. On EKS with security groups for pods, the same symptom comes from a security group that does not allow the node or caller ENI. If the timeout is only at the edge and in-cluster calls work, continue with the ingress 502/503/504 guide.
Prevention
Alert on empty Services. With kube-state-metrics, a Service that has zero ready addresses exports no address series at all, so alert on the absence:
- alert: ServiceHasNoReadyEndpoints
expr: |
kube_endpoint_info{namespace!~"kube-system|dev-.*"}
unless on (namespace, endpoint)
kube_endpoint_address{ready="true"}
for: 5m
labels:
severity: page
annotations:
summary: "Service {{ $labels.namespace }}/{{ $labels.endpoint }} has no ready endpoints"
Metric names vary between kube-state-metrics releases (older versions expose kube_endpoint_address_available), so run the expression in Prometheus before you ship the rule. Exclude Services that are meant to be empty, such as scale-to-zero workloads.
Check selectors in CI. After rendering manifests, fail the build if any Service selector matches no pod template in the same render. Server-side dry-run will not catch it, because an empty selector match is valid Kubernetes.
Use named ports everywhere. Name the container port once (name: web) and reference it from the Service targetPort and from every probe. A port change then becomes a one-line edit and cannot leave the Service pointing at the old number.
Keep dependencies out of readiness. One slow database should degrade responses and leave the endpoints alone.
Quick reference
| Evidence | Cause | Fix |
|---|---|---|
| EndpointSlice empty, selector query returns no pods | Label or namespace mismatch | Patch the Service selector, then fix it in Git |
Endpoints present with ready=false, pods 0/1 Running | Readiness probe failing | Fix the probe path, port, or dependency check |
Pods 1/1, READINESS GATES 0/1 | External controller has not set its condition | Debug that controller |
Deployment 0/0 | Scaled to zero | Scale up, or front it with a request-holding proxy |
| SELECTOR shows none, no slices | Manual EndpointSlice missing or mislabeled | Add the kubernetes.io/service-name label and match the port name |
Pods Ready, named targetPort not on the container | Port name unresolved | Make the names match exactly |
ready=true, refused on the pod IP | Wrong numeric targetPort or 127.0.0.1 bind | Correct the port, bind 0.0.0.0 |
ready=true, timeout | NetworkPolicy or security group | Allow the caller on the pod's port |