minikube - how to access pod via pod ip using curl
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Minikube, pods get internal IP addresses from the cluster's pod network (typically 172.17.x.x or 10.244.x.x). These IPs are not directly accessible from the host machine because Minikube runs inside a VM or container with its own network. To curl a pod by its IP, you need to either SSH into the Minikube node with minikube ssh, use kubectl port-forward, or access the pod through a Service. Understanding the networking model helps you choose the right approach for debugging, testing, and development.
Finding the Pod IP
The pod IP is assigned by the cluster's CNI (Container Network Interface) plugin. It is internal to the Minikube node and not routable from the host by default.
Method 1: minikube ssh + curl
minikube ssh places you inside the Minikube node where pod IPs are directly accessible. This is the quickest way to test a pod's HTTP endpoint during debugging.
Method 2: kubectl port-forward
kubectl port-forward creates a tunnel from localhost to the pod. This is the standard way to access pods from your host machine without creating a Kubernetes Service.
Method 3: Create a Service
A NodePort service maps a port on the Minikube node to the pod. minikube service resolves the full URL, which is accessible from your host.
Method 4: kubectl exec with curl
Running curl from inside a pod works because all pods on the same cluster can reach each other by IP. This also lets you test DNS-based service discovery.
Using Minikube Tunnel for LoadBalancer Services
minikube tunnel creates a network route from your host to the cluster's service CIDR, making LoadBalancer services accessible from localhost or their assigned IPs.
Debugging Network Issues
Common Pitfalls
- Trying to curl pod IPs from the host machine directly: Pod IPs are internal to the Minikube node's network and not routable from the host. Use
minikube ssh,kubectl port-forward, or a NodePort/LoadBalancer service to access pods from your host. - Forgetting that pod IPs change on restart: Pods get new IPs every time they are recreated. Never hardcode pod IPs — use Kubernetes Services for stable endpoints. Services provide a stable ClusterIP and DNS name (
service-name.namespace.svc.cluster.local). - Using the wrong Minikube driver affecting networking: Minikube with the Docker driver has different networking than VirtualBox or Hyperkit.
minikube ipmay return127.0.0.1on Docker driver, in which caseminikube service --urlis the only reliable way to get an accessible URL. - Not running
minikube tunnelfor LoadBalancer services: Withoutminikube tunnel,LoadBalancerservices show<pending>as their external IP forever. The tunnel must be running in a terminal for the service to get an IP. It requires sudo because it modifies the host's routing table. - Port conflicts with
kubectl port-forward: If local port 8080 is already in use,port-forwardsilently fails or shows an error. Use a different local port:kubectl port-forward pod/nginx 9090:80maps local 9090 to pod 80.
Summary
- Pod IPs are internal to Minikube — not directly accessible from the host
- Use
minikube ssh -- curl http://<pod-ip>:<port>for quick debugging - Use
kubectl port-forwardfor host access without creating a Service - Create a
NodePortservice and useminikube service <name> --urlfor stable access - Use
minikube tunnelforLoadBalancerservices - Never rely on pod IPs — they change on pod restart; use Services for stable networking

