# TCPingress mongodb

**URL:** https://discuss.konghq.com/t/tcpingress-mongodb/8042
**Category:** General
**Tags:** kubernetes
**Created:** [March 14, 2021, 7:12pm UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042 "2021-03-14T19:12:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![samsja](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/samsja/32/1381_2.png) [@samsja](https://discuss.konghq.com/u/samsja)
#### Post date: [March 14, 2021, 7:12pm UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042/1 "2021-03-14T19:12:30Z")

</div>

Hi,

I have a mongodb deployment on my k8s cluster.

I want to expose the service via the kong tcpingress.

```auto

apiVersion: configuration.konghq.com/v1beta1
kind: TCPIngress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: letsencrypt-production-issuer
    kubernetes.io/ingress.class: "kong"
    nginx.ingress.kubernetes.io/use-regex: "true"
    konghq.com/strip-path: "true"
  name: ingress-mongodb
  namespace: mongodb
spec:
  rules:
    - host: HOST 
      backend:
        serviceName: mongodb-svc
        servicePort: 27017

```

However when I try to connect to my it I got the following response

```auto
mongo --host HOST --username mongodb-admin --password PASSWORD --port 80

```

```auto
MongoDB shell version v4.4.4
connecting to: mongodb://HOST:80/?compressors=disabled&gssapiServiceName=mongodb
Error: network error while attempting to run command 'isMaster' on host 'HOST:80' :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

```

I precise that when I did a port forwarding via kubectl port-forward I can connect.

I suppose that something is wrong with my TCPingress configuration, what am I missing ?

Thanks in advance

```auto
kong version : 2.1.4
kong ingress controller : 0.10.0 with pgsql Database

```

---

<div class="post-metadata">

### Author: ![pacobuenaparte](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/pacobuenaparte/32/2671_2.png) [@pacobuenaparte](https://discuss.konghq.com/u/pacobuenaparte)
#### Post date: [March 30, 2021, 5:56pm UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042/2 "2021-03-30T17:56:04Z")

</div>

Same for me, please somebody help ?

---

<div class="post-metadata">

### Author: ![erikhh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/erikhh/32/2641_2.png) [@erikhh](https://discuss.konghq.com/u/erikhh)
#### Post date: [April 9, 2021, 1:47pm UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042/3 "2021-04-09T13:47:14Z")

</div>

I think you might need to add

```auto
- name: KONG_STREAM_LISTEN
          value: "0.0.0.0:27017"

```

To the environment of the `proxy` container of the `ingress-kong` pod.

---

<div class="post-metadata">

### Author: ![Kangyi\_LI](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/kangyi_li/32/2652_2.png) [@Kangyi\_LI](https://discuss.konghq.com/u/Kangyi_LI)
#### Post date: [April 10, 2021, 9:13am UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042/4 "2021-04-10T09:13:59Z")

</div>

thank you so much ! it works

---

<div class="post-metadata">

### Author: ![rahulmr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/rahulmr/32/3910_2.png) [@rahulmr](https://discuss.konghq.com/u/rahulmr)
#### Post date: [April 2, 2023, 5:58am UTC](https://discuss.konghq.com/t/tcpingress-mongodb/8042/5 "2023-04-02T05:58:12Z")

</div>

Could you please post the complete solution? I am trying to expose mongodb using domainname and port by using ingress but I am not sure how it will work.
