<p>I am trying to access my ingress-nginx service from a service but it gives connection refused. Here is my ingress</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users/?(.*)
            backend:
              serviceName: auth-srv
              servicePort: 3000
          - path: /api/tickets/?(.*)
            backend:
              serviceName: tickets-srv
              servicePort: 3000
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000
</code></pre>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Namespace
metadata:
  name: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
---
kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: http
      port: 443
      protocol: TCP
      targetPort: https
</code></pre>

<pre><code>❯ kubectl get services -n ingress-nginx
NAME            TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                      AGE
ingress-nginx   LoadBalancer   10.101.124.218   10.101.124.218   80:30634/TCP,443:30179/TCP   15m
</code></pre>

<p>The ingress-nginx is running on namespace ingress-nginx.
So it should be accessible by <code>http://ingress-nginx.ingress-nginx.svc.cluster.local</code>. But when I access it, it says <code>connection refused 10.101.124.218:80</code>. I am able to access the ingress from outside, i.e. from the <code>ingress</code> ip.</p>

<p>I am using minikube and used ingress by running <code>minikube addons enable ingress</code>. Yes and im running the tunnel by <code>minikube tunnel</code></p>

<p>I tested your environment and found the same behavior, external access but internally getting connection refused, this is how I solved:</p>

<ul>
<li>The Minikube Ingress Addon deploys the controller in <code>kube-system</code> namespace. If you try to deploy the service in a newly created namespace, it will not reach the deployment in <code>kube-system</code> namespace. </li>
<li>It's easy to mix those concepts because the default <code>nginx-ingress</code> deployment uses the namespace <code>ingress-nginx</code> as you were trying.</li>
<li><p>Another issue I found, is that your service does not have all selectors assigned to the controller deployment.</p></li>
<li><p>The easiest way to make your deployment work, is to run <code>kubectl expose</code> on the nginx controller:</p></li>
</ul>

<pre><code>kubectl expose deployment ingress-nginx-controller --target-port=80 --type=NodePort -n kube-system
</code></pre>

<ul>
<li>Using this command to create the nginx-ingress-controller service, all communications were working, both external and internal.</li>
</ul>

<hr>

<p><strong>Reproduction:</strong></p>

<ul>
<li>For this example I'm using only two ingress backends to avoid being much repetitive in my explanation.</li>
<li>Using minikube 1.11.0</li>
<li>Enabled <code>ingress</code> and <code>metallb</code> addons.</li>
<li>Deployed two hello apps: <code>v1</code> and <code>v2</code>, both pods listens on port <code>8080</code> and are exposed as node port as follows:</li>
</ul>

<pre><code>$ kubectl get services
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
hello1-svc   NodePort    10.110.211.119   &lt;none&gt;        8080:31243/TCP   95m
hello2-svc   NodePort    10.96.9.66       &lt;none&gt;        8080:31316/TCP   93m
</code></pre>

<ul>
<li>Here is the ingress file, just like yours, just changed the backend services names and ports to match my deployed ones:</li>
</ul>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users/?(.*)
            backend:
              serviceName: hello1-svc
              servicePort: 8080
          - path: /?(.*)
            backend:
              serviceName: hello2-svc
              servicePort: 8080
</code></pre>

<ul>
<li>Now I'll create the <code>nginx-ingress</code> service exposing the controller deployment, this way all tags and settings will be inherited:</li>
</ul>

<pre><code>$ kubectl expose deployment ingress-nginx-controller --target-port=80 --type=NodeP
ort -n kube-system
service/ingress-nginx-controller exposed
</code></pre>

<ul>
<li>Now we deploy the ingress object:</li>
</ul>

<pre><code>$ kubectl apply -f ingress.yaml 
ingress.networking.k8s.io/ingress-service created

$ kubectl get ingress
NAME              CLASS    HOSTS           ADDRESS      PORTS   AGE
ingress-service   &lt;none&gt;   ticketing.dev   172.17.0.4   80      56s

$ minikube ip
172.17.0.4
</code></pre>

<ul>
<li>Testing the ingress from the outside:</li>
</ul>

<pre><code>$ tail -n 1 /etc/hosts
172.17.0.4 ticketing.dev

$ curl http://ticketing.dev/?foo
Hello, world!
Version: 2.0.0
Hostname: hello2-67bbbf98bb-s78c4

$ curl http://ticketing.dev/api/users/?foo
Hello, world!
Version: 1.0.0
Hostname: hello-576585fb5f-67ph5
</code></pre>

<ul>
<li>Then I deployed a <code>alpine</code> pod to test the access from inside the cluster:</li>
</ul>

<pre><code>$ kubectl run --generator=run-pod/v1 -it alpine --image=alpine -- /bin/sh
/ # nslookup ingress-nginx-controller.kube-system.svc.cluster.local
Server:         10.96.0.10
Address:        10.96.0.10:53

Name:   ingress-nginx-controller.kube-system.svc.cluster.local
Address: 10.98.167.112

/ # apk update
/ # apk add curl

/ # curl -H "Host: ticketing.dev" ingress-nginx-controller.kube-system.svc.cluster.local/?foo
Hello, world!
Version: 2.0.0
Hostname: hello2-67bbbf98bb-s78c4

/ # curl -H "Host: ticketing.dev" ingress-nginx-controller.kube-system.svc.cluster.local/api/users/?foo
Hello, world!
Version: 1.0.0
Hostname: hello-576585fb5f-67ph5
</code></pre>

<p>As you can see, all requests were fulfilled.</p>

<hr>

<p><strong>Note:</strong></p>

<ul>
<li><p>As pointed by <strong>@suren</strong>, when curling ingress, I had to specify the host with -H</p></li>
<li><p>The service name needs to be fully FQDN because we are dealing with a service hosted in another namespace, using the format <code>&lt;SVC_NAME&gt;.&lt;NAMESPACE&gt;.svc.cluster.local</code>.</p></li>
<li><p>In your JS app, you will have to pass the <code>Host</code> argument in order to reach the ingress.</p></li>
</ul>

<p>If you have any question let me know in the comments.</p>
