<p>These are my pods</p>

<pre><code>hello-kubernetes-5569fb7d8f-4rkhs   0/1     ImagePullBackOff   0          5d2h
hello-minikube-5857d96c67-44kfg     1/1     Running            1          5d2h
hello-minikube2                     1/1     Running            0          3m24s
hello-minikube2-74654c8f6f-trrrw    1/1     Running            0          4m8s
hello-newkubernetes                 0/1     ImagePullBackOff   0          5d1h
</code></pre>

<p>If I try</p>

<pre><code>curl $(minikube service hello-minikube2 --url)
curl: (7) Failed to connect to 192.168.99.100 port 31591: Connection refused
</code></pre>

<p>Let's check VBox</p>

<pre><code>inet 192.168.99.1/24 brd 192.168.99.255 scope global vboxnet0
   valid_lft forever preferred_lft forever
inet6 fe80::800:27ff:fe00:0/64 scope link 
   valid_lft forever preferred_lft forever
</code></pre>

<p>Why is my connection refused?</p>

<pre><code>kubectl get svc -o wide
NAME                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE     SELECTOR
hello-kubernetes    NodePort    10.98.65.138    &lt;none&gt;        8080:30062/TCP   5d2h    run=hello-kubernetes
hello-minikube      NodePort    10.105.166.56   &lt;none&gt;        8080:30153/TCP   5d3h    run=hello-minikube
hello-minikube2     NodePort    10.96.94.39     &lt;none&gt;        8080:31591/TCP   42m     run=hello-minikube2
kubernetes          ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP          5d4h    &lt;none&gt;
tomcat-deployment   NodePort    10.96.205.228   &lt;none&gt;        8080:30613/TCP   2m13s   app=tomcat

kubectl get ep -o wide
NAME                ENDPOINTS                         AGE
hello-kubernetes                                      5d14h
hello-minikube      172.17.0.7:8080                   5d14h
hello-minikube2     172.17.0.4:8080,172.17.0.5:8080   12h
kubernetes          192.168.99.100:8443               5d16h
tomcat-deployment   172.17.0.6:8080                   11h
</code></pre>

<p>I want to show service endpoint</p>

<pre><code>minikube service tomcat-deployment --url
http://192.168.99.100:30613
</code></pre>

<p>Why is this url different from get ep -o wide output?</p>

Richard Rublev
<p>Apparently, you are trying to reach your service outside of the cluster, thus you need to expose your service IP for external connection.</p>

<p>Run <code>kubectl edit svc hello-minikube2</code> and  change </p>

<pre><code>type: NodePort
</code></pre>

<p>to </p>

<pre><code>type: LoadBalancer
</code></pre>

<p>Or </p>

<pre><code>kubectl expose deployment hello-minikube2 --type=LoadBalancer --port=8080
</code></pre>

<p>On cloud providers that support load balancers, an external IP address would be provisioned to access the Service. On Minikube, the LoadBalancer type makes the Service accessible through the minikube service command.</p>

<p>Run the following command:</p>

<pre><code>minikube service hello-minikube2
</code></pre>
