[英]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.