2013-01-22 52 views
3

我試圖通過運行命令「的Heroku PG:PSQL」連接到Postgres數據庫爲我的應用程序在Heroku上,並得到了以下錯誤消息:Heroku的PG:PSQL不工作

psql: could not connect to server: Connection timed out (0x0000274C/10060) 
    Is the server running on host "URL.com"(IP address) and accepting 
    TCP/IP connections on port 5432? 

我也試着連接使用Pgadmin並且得到錯誤:

Server doesn't listen. Is the server running on host "URL.com" (IP address) and accepting 
    TCP/IP connections on port 5432? 

誰能告訴我如何修復這些錯誤,並正確連接到我的數據庫。 在此先感謝!

回答

0

試試這個:

heroku pg:psql DATABASE_URL 
0

由於開始有一些事情要考慮使用DATABASE_URL暗示了。

如果您在Heroku中有多個應用程序,那麼指定要添加數據庫的應用程序的連接總是很好的。如果您有多個數據庫來指定數據庫名稱(如果它不是默認的DATABASE_URL),則同樣適用。

一些例子如何連接:

-- Defining to what DB and app you want to connect to: 
heroku pg:psql [lower case generated name] -a myapp 
heroku pg:psql [lower case generated name] --app myapp 
heroku pg:psql HEROKU_POSTGRESQL_[upper case generated name]_URL -a myapp 

-- This will fall back to default DATABASE_URL part of your app: 
heroku pg:psql -a myapp 

而且要記住這裏https://devcenter.heroku.com/articles/heroku-local#copy-heroku-config-vars-to-your-local-env-file說:

Keep in mind that your deployed production app may be connecting to different services than your local development app. For example, your deployed production app might have a DATABASE_URL config var that references a Heroku Postgres database, but your local app might have a DATABASE_URL variable in the .env file that references your local installation of Postgres.

Heroku的指導方針 - https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql(但它說明了一點關於多數據庫和多應用案例)。

Heroku的指導方針進行外部連接 - https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku

+0

要人誰正確安裝並設置自己的PATH變量 - 請務必重新打開CMD或PowerShell的。更新後的變量在您執行之前不會生效。 – ophilbinbriscoe