我想部署我的django应用程序在heroku服务器上,我按照这个网站的指示https://devcenter.heroku.com/articles/getting-started-with-python#introduction。它工作得很好,直到“heroku open”command.When我来到我需要使用“heroku运行python manage.py syncdb”命令托管我的数据库的部分,它失败显示消息“OperationalError:无法连接到服务器:连接被拒绝 服务器是否在主机”localhost“(127.0。 0.1)并且接受端口5432上的TCP/IP连接 ?“。我尝试了很多修复,包括这里建议的一个,其中包括Deploying Django app's local postgres database to heroku?和http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html。我尝试了所有解决方案,包括在postgresql.conf中编辑“listen_address”='*'和tcpip_socket ='true',并编辑pg_hba.conf中的ipv4和v6值到 主机全部全部127.0.0.1 255.255.0.1信任 主机全部全部10.0.0.99/32 md5 主机全部全部0.0.0.0/0。同时depheroing django应用程序在heroku上postgres不起作用
但他们都没有工作。我猜测问题的出现是因为heroku无法连接到我的本地postgres服务器。这很奇怪,因为我能够通过pgadmin访问postgres服务器。
而且也是在Django的settings.py看起来像这样
数据库= { '默认': { 的 '发动机': 'django.db.backends.postgresql_psycopg2', 'NAME': 'django_test', 'USER':'postgres', 'PASSWORD':'******', 'HOST':'localhost',#或您的数据库托管的IP地址 'PORT ':'5432', } } 我需要改变它并使用heroku的数据库设置吗?
因此postgres服务器位于heroku服务器上,对吗? – electrometro
没有它在我的本地系统 –
但如果我给postgres分贝,我在heroku上创建的服务器url(它以“postgres // xxxxxxxxxxxxxx”开头,它说不能翻译地址 –