<p>I am trying to deploy nginx image from docker hub to kubernetes cluster.</p>

<p>This is the steps I did -</p>

<pre><code>docker pull nginx
kubectl run nginx --image=nginx --port=8080 --image-pull-policy=IfNotPresent
kubectl expose deployment nginx --type=LoadBalancer --port=80 --target-port=8080 --name=nginx

xxx@cloudshell:~ (involuted-ratio-227118)$ kubectl get svc
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)        AGE
kubernetes   ClusterIP      10.51.240.1     &lt;none&gt;         443/TCP        2d
nginx        LoadBalancer   10.51.252.202   34.73.115.78   80:30355/TCP   8m
nginx-http   ClusterIP      10.51.254.159   &lt;none&gt;         80/TCP         1d
</code></pre>

<p>Below is the error displayed on accessing external endpoint URL -</p>

<p>The following error was encountered while trying to retrieve the URL: <a href="http://34.73.115.78/" rel="nofollow noreferrer">http://34.73.115.78/</a></p>

<p>Connection to 34.73.115.78 failed.
The system returned: (111) Connection refused
The remote host or network may be down. Please try the request again.
Your cache administrator is webmaster.</p>

<p>But I see nginx deployed and also service endpoint showing without any errors in kubernetes-dashboard. I even checked nginx pod logs and this is what is displayed -
The selected container has not logged any messages yet.</p>

<p>Any help is appreciated. Thanks</p>

Gopi
<p>nginx run in port <code>80</code>. But you are trying to connect in port <code>8080</code>. That's why you are getting error. Try this instead:</p>

<pre><code>kubectl run nginx --image=nginx --port=80 --image-pull-policy=IfNotPresent

kubectl expose deployment nginx --type=LoadBalancer --port=80 --target-port=80 --name=nginx
</code></pre>
