加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails 4 Heroku postgreSQL错误

发布时间:2020-12-17 02:40:08 所属栏目:百科 来源:网络整理
导读:我在使用SQLite3将现有应用程序更改为postgreSQL时遇到了问题.我正在按照本教程将SQLite3转换为postgreSQL并将其部署到heroku: https://devcenter.heroku.com/articles/sqlite3#running-rails-on-postgres. 我删除了gem’sqlite3’并替换为gem’pg’. 修改c
我在使用SQLite3将现有应用程序更改为postgreSQL时遇到了问题.我正在按照本教程将SQLite3转换为postgreSQL并将其部署到heroku: https://devcenter.heroku.com/articles/sqlite3#running-rails-on-postgres.

我删除了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"?

解决方法

您好像没有在Heroku帐户中添加Heroku Postgres数据库.配置数据库后,您的应用程序将连接到该数据库.如果没有配置数据库,它将回退到本地查找数据库.

如果您确实配置了数据库,则Heroku环境会出现问题,导致无法找到数据库连接设置.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读