简体   繁体   English

kubernetes 上的 Postgres+django:django.db.utils.OperationalError:无法连接到服务器:连接超时

[英]Postgres+django on kubernetes: django.db.utils.OperationalError: could not connect to server: Connection timed out

My Django app can't connect to the Postgres server on Kubernetes.我的 Django 应用程序无法连接到 Kubernetes 上的 Postgres 服务器。 All other pods are able to connect to this Postgres server and creds are valid as well, any idea why not this Django app所有其他 pod 都能够连接到此 Postgres 服务器,并且凭据也有效,知道为什么不使用此 Django 应用程序

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? django.db.utils.OperationalError:无法连接到服务器:连接超时服务器是否在主机“postgres-postgresql”(10.245.56.118)上运行并接受端口 5342 上的 TCP/IP 连接?

Picture of the problem.问题的图片。 I login into the django app container and tried to connect via Django's data access layer and psql.我登录到 django 应用程序容器并尝试通过 Django 的数据访问层和 psql 进行连接。 Only psql is working without any problems只有 psql 工作没有任何问题

在此处输入图像描述

postgres: postgres:

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

Kubernetes: 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

That chart configured Postgres to listen on port 5432. You tried to connect to port 5342. Those are different.该图表将 Postgres 配置为侦听端口 5432。您尝试连接到端口 5342。这些是不同的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 django.db.utils.OperationalError:无法连接到服务器:连接被拒绝 - django.db.utils.OperationalError: could not connect to server: Connection refused Postgres django.db.utils.OperationalError:无法连接到服务器:连接被拒绝 - Postgres django.db.utils.OperationalError: could not connect to server: Connection refused Django 与 Docker 上的 postgreSQL DB - django.db.utils.OperationalError:无法连接到服务器:连接被拒绝 - Django with postgreSQL DB on Docker - django.db.utils.OperationalError: could not connect to server: Connection refused django.db.utils.OperationalError:无法连接到服务器:没有这样的文件或目录 - django.db.utils.OperationalError: could not connect to server: No such file or directory django.db.utils.OperationalError 无法连接到服务器 - django.db.utils.OperationalError Could not connect to server PostgreSQL-django.db.utils.OperationalError:无法连接到服务器:连接被拒绝 - postgresql - django.db.utils.OperationalError: could not connect to server: Connection refused 得到 django.db.utils.OperationalError:无法连接到服务器:连接被拒绝 - Got django.db.utils.OperationalError: could not connect to server: Connection refused Docker 和 Django。 django.db.utils.OperationalError: 无法连接到服务器 - Docker and Django. django.db.utils.OperationalError: could not connect to server 在 Dockerfile 中运行“manage.py compilemessages”给出“django.db.utils.OperationalError:无法连接到服务器:没有这样的文件或目录” - Running “manage.py compilemessages” in Dockerfile gives “django.db.utils.OperationalError: could not connect to server: No such file or directory” django.db.utils.OperationalError:无法连接到服务器:Unix 域套接字“/tmp/.s.PGSQL.5432”上没有此类文件? - django.db.utils.OperationalError: could not connect to server: No such file on Unix domain socket “/tmp/.s.PGSQL.5432”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM