【问题标题】:Rails 4 Heroku postgreSQL ErrorRails 4 Heroku postgreSQL错误
【发布时间】:2014-02-04 22:46:35
【问题描述】:

我无法将使用 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"?

【问题讨论】:

  • 阅读错误信息。你检查了它告诉你检查的东西吗?您是否搜索过错误消息?我敢打赌你可能也在 Mac 上,在这种情况下,将“OS X”添加到该搜索中,因为对于 PostgreSQL + Rails 的 Mac 用户来说,这是一个常见的问题。很难提供更多帮助,因为您没有提供 PostgreSQL 版本或安装 PostgreSQL 的方式,或您的操作系统和版本

标签: ruby-on-rails postgresql heroku


【解决方案1】:

您似乎尚未将 Heroku Postgres 数据库添加到您的 Heroku 帐户。配置数据库后,您的应用程序将连接到它。如果没有配置数据库,它会回退到在本地寻找一个。

如果您确实配置了数据库,则说明您的 Heroku 环境有问题,导致无法找到您的数据库连接设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2016-04-07
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 2012-04-12
    相关资源
    最近更新 更多