curl: (7) Failed connect to xx.xx.xx.xx:80; Connection refused

9/21/2018

I am trying to deploy nginx - ingress

kubectl run nginx --image=nginx

kubectl get pod 
NAME                                       READY     STATUS        RESTARTS   AGE
nginx-65899c769f-wf7dl                     1/1       Running       0          9m


kubectl expose deploy nginx --port 80
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
nginx        ClusterIP   10.254.75.184      <none>     80/TCP           9m

vi ingress.yml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
spec:
  rules:
    - host: kub-mst.coral.io
      http:
        paths:
          - backend:
              serviceName: nginx
              servicePort: 80

kubectl get ing
NAME      HOSTS              ADDRESS   PORTS     AGE
nginx     kub-mst                      80        9m

vi /etc/hosts
xx.xx.xx.xx  kub-mst.coral.io

curl kub-mst.coral.io
curl: (7) Failed connect to kub-mst; Connection refused

I have Kubernetes Cluster and am trying to

curl http://xx.xx.xx.xx

it returns

curl: (7) Failed connect to xx.xx.xx.xx:80; Connection refused

and i execute

kubectl cluster-info

it returns

Kubernetes master is running at http://localhost:8080
KubeDNS is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

xx.xx.xx.xx is public IP.

how to troubleshooting to detect where is the problem

-- AhmedMItman
curl
kubernetes
kubernetes-ingress
ssl

1 Answer

9/27/2018

You provided the ingress controller with a single rule that matches the host header of your request, yet, for some odd reason, you're testing with a request that does not provide the host header.

curl -H 'Host: kub-mst.coral.io' http://xx.xx.xx.xx

-- samhain1138
Source: StackOverflow