2014-01-16 59 views
4

我在使用SQLite3將現有應用程序更改爲postgreSQL時遇到問題。我正在學習本教程將SQLite3轉換爲postgreSQL並將其部署到heroku:https://devcenter.heroku.com/articles/sqlite3#running-rails-on-postgresRails 4 Heroku postgreSQL錯誤

我刪除了gem'sqlite3'並換成了gem'pg'。 修改config/database.yml後,我運行遷移。

$rake db:create$rake db:migrate導致這個錯誤:

could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

的Gemfile在生產中使用:

gem 'rails_12factor' 
gem 'thin' 
gem 'pg' 

以下是當我在本地服務器上運行,我得到的錯誤:

/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad) 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 
+1

閱讀錯誤消息。你檢查了它告訴你檢查的東西嗎?您是否搜索錯誤消息?我敢打賭你也可能在Mac上,在這種情況下,爲該搜索添加「OS X」,因爲這是PostgreSQL + Rails的Mac用戶的v.common問題。很難幫助更多,因爲*您沒有包含PostgreSQL版本,或者您如何安裝PostgreSQL,或者您的操作系統和版本*。 –

回答

5

它看起來像你還沒有添加Heroku Postgres數據庫給你r Heroku帳戶。在配置數據庫時,您的應用程序將連接到它。如果沒有配置數據庫,它會回落到本地尋找。

如果您確實已經配置了數據庫,Heroku環境會出現問題,導致無法找到您的數據庫連接設置。