【问题标题】:django postgres could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1)django postgres 无法连接到服务器:连接被拒绝服务器是否在主机“localhost”(127.0.0.1)上运行
【发布时间】:2019-06-02 09:11:36
【问题描述】:

我刚刚使用Zappaaws-lambda 上部署Django 应用程序,但出现错误。我不知道我是否必须安装 Postgres,因为我认为它是从 requirements.txt 自动安装的

OperationalError at /admin/login/ could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

Request Method:     POST
Request URL:    https://tmzgl5al3h.execute-api.ap-south-1.amazonaws.com/dev/admin/login/?next=%2Fdev%2Fadmin%2F
Django Version:     2.1.4
Exception Type:     OperationalError
Exception Value:    could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

Exception Location:     /var/task/psycopg2/__init__.py in connect, line 130
Python Executable:  /var/lang/bin/python3.6
Python Version:     3.6.1
Python Path:        ['/var/task', '/opt/python/lib/python3.6/site-packages', '/opt/python', '/var/runtime', '/var/runtime/awslambda', '/var/lang/lib/python36.zip', '/var/lang/lib/python3.6', '/var/lang/lib/python3.6/lib-dynload', '/var/lang/lib/python3.6/site-packages', '/opt/python/lib/python3.6/site-packages', '/opt/python', '/var/task']

【问题讨论】:

    标签: python django postgresql aws-lambda python-zappa


    【解决方案1】:

    PostgreSQL 不是 python 库而是一个独立的开源数据库,你一定要设置它

    在 AWS 领域,您应该将其设置为 RDS 实例并相应地配置您的环境

    【讨论】:

    • 如何将本地 Postgres 上传到 rds
    • 我在 rds 上创建了 db
    • 在你的 Django 设置 DATABASES var 中相应地使用你的用户、密码、数据库 url。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 2019-02-20
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多