简体   繁体   English

EC2安全组上的Django RDS上的PostgreSQL

[英]Django on EC2 security group fo postgresql on RDS

edited the DATABASES entry in my settings.py to be: 在我的settings.py中将DATABASES条目编辑为:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'Limbo',
        'USER': '<username>',
        'PASSWORD': '<password>',
        'HOST': '<dbname>.<gibberish>.us-west-2.rds.amazonaws.com',
        'PORT': '5432',
    }
}

now when I .manage.py runserver 0.0.0.0:800 , it says: 现在当我.manage.py runserver 0.0.0.0:800 ,它说:

Performing system checks... 正在执行系统检查...

System check identified no issues (0 silenced). 系统检查未发现任何问题(0静音)。

then after a minute or two: 一两分钟后:

File "/home/ec2-user///local/lib64/python2.7/site-packages/psycopg2/ init .py", line 164, in connect conn = _connect(dsn, connection_factory=connection_factory, async=async) django.db.utils.OperationalError: could not connect to server: Connection timed out Is the server running on host "..us-west-2.rds.amazonaws.com" (172.rest.of.ip) and accepting TCP/IP connections on port 5432? 在连接conn = _connect(dsn,connection_factory = connection_factory,async = async)中的文件“ /home/ec2-user////local/lib64/python2.7/site-packages/psycopg2/ init .py”,行164 .db.utils.OperationalError:无法连接到服务器:连接超时服务器是否正在主机“ ..us-west-2.rds.amazonaws.com”(172.rest.of.ip)上运行并接受TCP /端口5432上的IP连接?

I have made sure to include the access via 5432 incoming from my ec2's IP (verified with curl ifconfig.co ) and the ip listed in the error message (starting with 172 above). 我已确保包括通过ec2的IP(已通过curl ifconfig.co验证)和错误消息中列出的ip(从上面的172开始)传入的5432的访问。 perhaps I need to use a larger subnet (than 32)in the 172 source? 也许我需要在172源中使用更大的子网(超过32个)?

EDIT: same error when I run python limbo/manage.py migrate EDIT2: if I allow 5432 connections from any IP in the security group it works, but as stated above, I am allowing my EC2's IP (according to curl ifconfig.co 's return value. what other IP should I be including? 编辑:运行python limbo/manage.py migrate时出现相同的错误EDIT2:如果我允许安全组中任何IP的5432连接有效,但是如上所述,我允许EC2的IP(根据curl ifconfig.co ' s的返回值,我还应该包括其他IP?

enter the following into the linux command line: cd /path/to/djangoproj screen source <env>/bin/activate 在linux命令行中输入以下内容: cd /path/to/djangoproj screen source <env>/bin/activate

then you should see the command line tool reads something like: (<env>)[ec2-user@ip-172-31-26-243 djangoproj]$ 那么您应该会看到命令行工具显示如下内容: (<env>)[ec2-user@ip-172-31-26-243 djangoproj]$

see that section in the middle: ip-172-31-26-243 , that's the local ip, use that in the security group settings. 请参阅中间的部分: ip-172-31-26-243 ,即本地ip,在安全组设置中使用它。 in this case, I used 172.31.26.243/32 as the incoming IP allowed 在这种情况下,我使用172.31.26.243/32作为允许的传入IP

then try to runserver again 然后尝试runserver再次

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

相关问题 在AWS EC2和RDS上使用Django - Django on AWS EC2 and RDS 使用RDS在EC2上使用Django - Django on EC2 using RDS Django + PostgreSQL 在 EC2 实例上备份和恢复 - Django + PostgreSQL backup and restore on an EC2 instance 如何将EC2中的Django连接到RDS中的Postgres数据库? - how to connect Django in EC2 to a Postgres database in RDS? Django与AWS EC2上的GeoDjango,RDS上的Postgres Postgis - Django with GeoDjango on AWS EC2, Postgres Postgis on RDS 无法从 EC2 Django 实例连接到 Amazon RDS - Not able to connect to Amazon RDS from EC2 Django Instance 在两个不同的EC2实例上设置Django和PostgreSQL - Setting Up Django and PostgreSQL on two different EC2 instances 相对于对象管理器(EC2),PostGIS(RDS)中的Django空间计算效率如何? - Django spatial calculations efficiency in PostGIS (RDS) vs. in object manager (EC2)? EC2 和 RDS 上的 Django 应用程序(服务器是否在主机“localhost”(127.0.0.1)上运行并在端口 5432 上接受 TCP/IP 连接?) - Django application on EC2 and RDS ( Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?) 将 Ubuntu EC2 上的 Django 连接到 AWS RDS MySQL:pymysql 尝试连接到 localhost 而不是外部服务器 - Connecting Django on Ubuntu EC2 to AWS RDS MySQL: pymysql tries to connect to localhost instead of foreign server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM