0

My Django app can't connect to the Postgres server on Kubernetes. All other pods are able to connect to this Postgres server and creds are valid as well, any idea why not this Django app

django.db.utils.OperationalError: could not connect to server: Connection timed out Is the server running on host "postgres-postgresql" (10.245.56.118) and accepting TCP/IP connections on port 5342?

Picture of the problem. I login into the django app container and tried to connect via Django's data access layer and psql. Only psql is working without any problems

enter image description here

postgres:

https://github.com/cetic/helm-postgresql

Kubernetes:

apiVersion:  apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    githubdir.service: valnet
  name: valnet
spec:
  selector:
    matchLabels:
      app: valnet
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: valnet
    spec:
      containers:
        - args:
          env:
          - name: VALNET_DATABASE_USER
            value: "postgres"
          - name: VALNET_DATABASE_PASSWORD
            value: "gdrBP9xxDZ"
          - name: VALNET_DATABASE_HOST
            value: "postgres-postgresql"
          - name: VALNET_DATABASE_PORT
            value: "5342"
          image: donutloop/valnet:v0.3.0
          name: valnet
          ports:
            - containerPort: 8000
          resources: {}
      restartPolicy: Always
5
  • Do you have any network policy in namespace? Commented May 10, 2020 at 15:06
  • I append to my post the Kube spec and I used Psql to connect with this Postgres server and worked without any problems. Only this django app has some problems Commented May 10, 2020 at 15:12
  • from where you used the psql to connect to it? Commented May 10, 2020 at 15:25
  • From inside of this Django container and from other containers Commented May 10, 2020 at 15:25
  • i added a picture of this problem Commented May 10, 2020 at 17:47

1 Answer 1

2

That chart configured Postgres to listen on port 5432. You tried to connect to port 5342. Those are different.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.