# KongIngress admin cannot connect with postgresql

**URL:** <https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324>\
**Category:** Questions\
**Tags:** kubernetes\
**Created:** [August 27, 2019, 9:23am UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324 "2019-08-27T09:23:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzhengzhuo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/zzhengzhuo/32/1723_2.png) [@zzhengzhuo](https://discuss.konghq.com/u/zzhengzhuo)\
**Post date:** [August 27, 2019, 9:23am UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324/1 "2019-08-27T09:23:26Z")

</div>

Thank you for your time to read my question.  
I just install kubernetes in my local cluster and install kongIngress by kong-dist-kubernetes.However when I curl $(kong\_admin\_ip),it returns like this:

```auto
HTTP/1.1 500 Internal Server Error
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 42
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Aug 2019 08:49:57 GMT
Server: kong/1.3.0

{
    "message": "An unexpected error happened"
}

```

And when I curl $(kong\_admin\_ip)/status,it returns like this:

```auto
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 962
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Aug 2019 08:51:34 GMT
Server: kong/1.3.0

{
    "database": {
        "reachable": false
    }, 
...

```

Then I kubectl log kong-control-plane-7dc44c48c9-6r74q.It said:

```auto
 2019/08/27 09:33:07 [error] 31#0: *113661 [lua] kong.lua:151: fn(): failed to connect to PostgreSQL during /status endpoint check:
 [PostgreSQL error] [cosocket] DNS resolution failed: dns server error: 3 name error. Tried: 
["(short)postgres.kong.svc:(na) - cache-miss",
"postgres.kong.svc.kong.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns client error: 101 empty record received",
"postgres.kong.svc.localdomain:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.kong.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns client error: 101 empty record received",
"postgres.kong.svc.localdomain:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.kong.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.localdomain:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:5 - cache-hit/stale/scheduled/dns server error: 3 name error"], client: 172.17.3.1, server: kong_admin, request: "GET /status HTTP/1.1", host: "172.17.3.5:8001"
172.17.3.1 - - [27/Aug/2019:09:33:07 +0000] "GET /status HTTP/1.1" 200 962 "-" "kube-probe/1.14" 

```

I thought it may result from the error of kube-dns,however when I check ,it returns like this:

```bash
/ # nslookup postgres.kong.svc.cluster.local
nslookup: can't resolve '(null)': Name does not resolve

Name: postgres.kong.svc.cluster.local
Address 1: 10.68.221.212 postgres.kong.svc.cluster.local

```

Maybe it is a stupid question,but I cannot find the answer by myself.Thank you for your help again.

#### dubug with kube-debugger

When I debug pod postgres and kong-control-plane by kube-debugger,I find it that when I curl postgres.kong.svc.cluster.local:5432,I can tcpdump packages in pod postgres,but I cannot tcpdump packages for port 5432 usually.

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [August 27, 2019, 3:59pm UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324/2 "2019-08-27T15:59:43Z")

</div>

Could you share the manifest that you are using to install and run Kong?

---

<div class="post-metadata">

**Author:** ![swapnild2111](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/swapnild2111/32/1197_2.png) [@swapnild2111](https://discuss.konghq.com/u/swapnild2111)\
**Post date:** [August 27, 2019, 10:05pm UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324/3 "2019-08-27T22:05:09Z")

</div>

Have you whitelisted your public ip address on Postgres security settings?

---

<div class="post-metadata">

**Author:** ![zzhengzhuo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/zzhengzhuo/32/1723_2.png) [@zzhengzhuo](https://discuss.konghq.com/u/zzhengzhuo)\
**Post date:** [August 28, 2019, 12:56am UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324/4 "2019-08-28T00:56:28Z")

</div>

Thank you for your reply.And do you mean that:

```bash
 # install kong 
 $ make run_postgres

kubectl apply -f kong-namespace.yaml
namespace/kong unchanged
./setup_certificate.sh
Generating a 2048 bit RSA private key
......+++
..........................+++
writing new private key to 'privkey.pem'
-----
certificatesigningrequest.certificates.k8s.io/kong-control-plane.kong.svc created
certificatesigningrequest.certificates.k8s.io/kong-control-plane.kong.svc approved
Error from server (AlreadyExists): secrets "kong-control-plane.kong.svc" already exists
make: [k8s_setup] 错误 1 (忽略)
kubectl -n kong apply -f postgres.yaml
service/postgres unchanged
replicationcontroller/postgres unchanged
kubectl -n kong apply -f kong-control-plane-postgres.yaml
serviceaccount/kong unchanged
role.rbac.authorization.k8s.io/kong unchanged
rolebinding.rbac.authorization.k8s.io/kong unchanged
deployment.extensions/kong-control-plane unchanged
service/kong-control-plane unchanged
kubectl -n kong apply -f kong-ingress-data-plane-postgres.yaml
deployment.extensions/kong-ingress-data-plane unchanged
service/kong-ingress-data-plane unchanged

 #run kong
 $ kubectl get pod -n kong -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kong-control-plane-7dc44c48c9-6r74q 1/1 Running 0 17h 172.17.3.5 172.20.10.11 <none> <none>
kong-ingress-data-plane-9bdd45b56-srr9r 1/1 Running 0 17h 172.17.2.4 172.20.10.10 <none> <none>
postgres-wbrhn 1/1 Running 0 17h 172.17.2.3 172.20.10.10 <none> <none>
$ kubectl get svc -n kong -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kong-control-plane NodePort 10.68.152.65 <none> 8001:33267/TCP,443:22316/TCP 17h app=kong-control-plane
kong-ingress-data-plane NodePort 10.68.96.157 <none> 8000:37465/TCP,8443:21882/TCP 17h app=kong-ingress-data-plane
postgres ClusterIP 10.68.221.212 <none> 5432/TCP 17h app=postgres

```

---

<div class="post-metadata">

**Author:** ![zzhengzhuo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/zzhengzhuo/32/1723_2.png) [@zzhengzhuo](https://discuss.konghq.com/u/zzhengzhuo)\
**Post date:** [August 28, 2019, 1:08am UTC](https://discuss.konghq.com/t/kongingress-admin-cannot-connect-with-postgresql/4324/5 "2019-08-28T01:08:22Z")

</div>

Thank you for your reply.And I have trid to connect to postgresql in my master node:

```auto
 $ psql -U kong -h 10.68.221.212 -p 5432

```

It work well.
