Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在AWS Elastic Beanstalk实例上手动运行python manage.py migrate命令_Python_Django_Postgresql_Amazon Web Services - Fatal编程技术网

无法在AWS Elastic Beanstalk实例上手动运行python manage.py migrate命令

无法在AWS Elastic Beanstalk实例上手动运行python manage.py migrate命令,python,django,postgresql,amazon-web-services,Python,Django,Postgresql,Amazon Web Services,我已经用命令创建了项目 :: eb create --database.engine postgres --region ap-southeast-1. 这表明我的部署是成功的。 另外,当我运行命令::eb open时,它成功地打开了我的项目网站 另外,当我在/var/log/eb-activity.log检查实例上的eb活动日志时,它还显示了我部署项目时迁移成功 但当我试图在Elastic Beanstalk实例上手动运行$python manage.py migrate时,它给出了错误 d

我已经用命令创建了项目

:: eb create --database.engine postgres --region ap-southeast-1.
这表明我的部署是成功的。 另外,当我运行命令
::eb open
时,它成功地打开了我的项目网站

另外,当我在/var/log/eb-activity.log检查实例上的eb活动日志时,它还显示了我部署项目时迁移成功

但当我试图在Elastic Beanstalk实例上手动运行
$python manage.py migrate
时,它给出了错误

django.db.utils.OperationalError: 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?
另外,当我尝试在python manage.py shell上手动创建用户时。这又是一个错误

django.db.utils.OperationalError: 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?
我想访问Elastikbeanstable实例上的postgres数据库,并想使用命令
$python manage.py migrate


有什么办法吗?

您需要更正数据库主机设置如果os.environ:DATABASES={'default':{'ENGINE':'django.DB.backends.postgresql\u psycopg2','NAME':os.environ['RDS\u DB\u NAME','USER':os.environ['RDS\u USERNAME',',“密码”:os.environ['RDS_PASSWORD'],“主机”:os.environ['RDS_HOSTNAME'],“端口”:os.environ['RDS_PORT'],}}和我的迁移在部署期间成功。这似乎不起作用,因为应用程序正在尝试连接数据库的本地主机。能否检查RDS_DB_NAME是否设置为环境变量?迁移成功?是,已设置。这是名称as=>export RDS\u DB\u name=“mydbname”您还可以检查“RDS\u主机名”和“RDS\u端口”的值吗?