Access pod localhost from Service

kubernetes access service from outside
kubernetes pod access external ip
access minikube service remotely
how to access nodeport service
kubectl port
access kubernetes api from outside
kubectl ssh tunnel
kubectl port-forward connection refused

New to Kubernetes.

I have a private dockerhub image deployed on a Kubernetes instance. When I exec into the pod I can run the following so I know my docker image is running:

root@private-reg:/# curl
Hello world!root@private-reg:/# 

From the dashboard I can see my service has an external endpoint which ends with port 8085. When I try to load this I get 404. My service YAML is as below:

  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "test",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/test",
    "uid": "a1a2ae23-339b-11e9-a3db-ae0f8069b739",
    "resourceVersion": "3297377",
    "creationTimestamp": "2019-02-18T16:38:33Z",
    "labels": {
      "k8s-app": "test"
  "spec": {
    "ports": [
        "name": "tcp-8085-8085-7vzsb",
        "protocol": "TCP",
        "port": 8085,
        "targetPort": 8085,
        "nodePort": 31859
    "selector": {
      "k8s-app": "test"
    "clusterIP": "******",
    "type": "LoadBalancer",
    "sessionAffinity": "None",
    "externalTrafficPolicy": "Cluster"
  "status": {
    "loadBalancer": {
      "ingress": [
          "ip": "******"

Can anyone point me in the right direction.

What is the output from the below command

curl cluzterIP:8085

If you get Hello world message then it means that the service is routing the traffic Correctly to the backend pod.

curl HostIP:NODEPORT should also be working

Most likely that service is not bound to the backend pod. Did you define the below label on the pod?

labels: {
      "k8s-app": "test"

Access a port of a pod locally :: Gardener, Run a web browser or curl locally and enter the URL http(s)://localhost:<local-port> Now you can access your Pod locally via localhost:<local-port>. Access any service from through the API proxy The Kubernetes API comes with an inbuilt proxy, which you can use to access Services deployed on your cluster.

You didn't mention what type of load balancer or cloud provider you are using but if your load balancer provisioned correctly which you should be able to see in your kube-controller-manager logs, then you should be able to access your service with what you see here:

"status": {
  "loadBalancer": {
    "ingress": [
      "ip": "******"

Then you could check by running:

$ curl <ip>:<whatever external port your lb is fronting>

It's likely that this didn't provision if as described in other answers this works:

$ curl <clusterIP for svc>:8085


$ curl <NodeIP>:31859 # NodePort

Access Services Running on Clusters, Access services, nodes, or pods using the Proxy Verb. example: http://localhost :8080/api/v1/namespaces/kube-system/services/elasticsearch� But.. when a POD tries to connect to localhost:9200 it can't connect. I also tried adding this ExternalName Service and curl minikube-host:9200, or even localhost:9200. Didn't make any difference.

Give a check on services on kuberntes, there are a few types:

ClusterIP: creates access to service only inside the cluster.

NodePort: Access service through a given port on the nodes.

LoadBalancer: service externally acessible through a LB.

I am assuming you are running on GKE.

What kind of service is it, the one launched?

Use Port Forwarding to Access Applications in a Cluster, Is it possible to access services running on the host from pod created by docker @minikube:~$ cat /etc/hosts localhost ::1 localhost� The ClusterIP enables the applications running within the pods to access the service. To make the service accessible from outside of the cluster a user can create a service of type NodePort. At first, let’s review the definition of the pod that we’ll expose using a NodePort service:

How to access service running on host OS from inside minikube VM , You can access Pods and services from outside your cluster either through Now you can access your Pod locally via localhost:<local-port> . This specification will create a Service which targets TCP port 80 on any Pod with the run: my-nginx label, and expose it on an abstracted Service port (targetPort: is the port the container accepts traffic on, port: is the abstracted Service port, which can be any port other pods use to access the Service).

Accessing Pods and Services from the outside – Giant Swarm , Use kubectl to quickly port-forward pods in a Kubernetes cluster. with internal Kubernetes cluster processes from your localhost. If a single pod starts failing, you are prepared to access that service and correct any issues. This page shows how to create an External Load Balancer. Note: This feature is only available for cloud providers or environments which support external load balancers. When creating a service, you have the option of automatically creating a cloud network load balancer. This provides an externally-accessible IP address that sends traffic to the correct port on your cluster nodes provided your

kubectl Port-Forward, An Ingress is an API object that defines rules which allow external access to services in a cluster. An Ingress controller fulfills the rules set in the� Kubectl port-forward allows you to access and interact with internal Kubernetes cluster processes from your localhost. You can use this method to investigate issues and adjust your services locally without the need to expose them beforehand. Kubectl is the principal command-line tool for managing Kubernetes clusters.

  • Nope, these both timeout. Seems something is not correctly set up?
  • You legend!! :D
  • I'm using Azure, but everything is managed by the main Kubernetes dashboard. Believe I'm using LoadBalancer - have added my service YAML to original question.
  • Do you have access to CLI on k8s, are you able to use kubectl command? if so, use kubectl get services, use it and get the external ip to access the service, you can cehck if the service is really load balancing.