Not able to fetch ip address of pods using Kubectl and jsonpath
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
If kubectl is not returning pod IP addresses through JSONPath, the problem is usually one of three things: the field path is wrong, the command is targeting a list when you wrote a single-object path, or the pod does not have an IP yet. The correct field is under .status, and whether you use .items[*] depends on whether the command returns multiple pods or one specific pod.
Use the Correct Field Path
For a single pod, the IP address lives at .status.podIP.
If you also want the pod name in the output:
A common mistake is to try .podIP or .spec.podIP. Those paths are wrong, so the command returns nothing and does not always explain why.
Query Multiple Pods With .items[*]
When the command returns a list, the JSON output contains an items array. That is why the JSONPath changes.
That prints the IPs for all pods in the current namespace. If you want one formatted line per pod, use a range expression.
If you need namespace information too:
Check Whether the Pod Actually Has an IP
A correct JSONPath still returns an empty value if the pod is not ready for networking. Pods in Pending often have no IP address yet.
If the result is Pending, check scheduling and events.
The lack of a pod IP may have nothing to do with JSONPath. The pod may simply not have been scheduled, or the cluster networking plugin may not have assigned an address yet.
Handle Common Variations
If the pod uses hostNetwork: true, the relevant address may be the host IP instead of a normal pod-network IP.
If you are working in a dual-stack cluster, you may also need the plural field.
That returns all assigned pod IPs instead of only the primary one.
Use Simpler Output Modes When Debugging
If JSONPath syntax is getting in the way, use a simpler output mode first to confirm the data exists.
or:
These are often easier to read during debugging. Once you confirm the field exists, move back to JSONPath for scripts or automation.
Common Pitfalls
The most common mistake is forgetting that .status.podIP is nested under .status. Another is using a list-style path like .items[*] when the command returns a single pod object, or the reverse.
Shell quoting is another frequent source of pain. Wrap the JSONPath in single quotes so the shell does not interfere with the braces and escape sequences.
Finally, do not assume every pod should already have an IP. A pod that is still pending, unschedulable, or blocked by CNI problems can correctly return an empty value.
Summary
- For one pod, use
.status.podIP. - For multiple pods, use
.items[*].status.podIPor arangeexpression. - Check pod phase if the field is empty, because the pod may not have an IP yet.
- Use
.status.hostIPor.status.podIPsfor special cases such as host networking or dual-stack clusters. - Fall back to
-o wideorcustom-columnswhen debugging field paths.
Related reading
- Not able to nslookup kubernetes.default
- Not able to SSH EKS Worker Nodes
- On kubernetes helm how to replace a pod with new config values
- One istio-ingressgateway and multiple TLS gateways
- One or more containers do not have resource limits - warning in VS Code Kubernetes tools
- OpenShift access service in other namespace without network join
- Openshift .kubeconfig file and certificate authentication
- Openshift pods not being deleted

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.