我想部署我的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」開頭,它說不能翻譯地址 –