gdf*_*dfg 1 ruby postgresql ruby-on-rails heroku ruby-on-rails-4
我将带有 PostgreSQL 的 Rails 5 部署到 Heroku 中的免费应用程序。这是我的配置database.yml:
production:
adapter: postgresql
username: root
password:
database: example
Run Code Online (Sandbox Code Playgroud)
当我运行时heroku run rake db:migrate,我看到这个错误:
耙子中止!PG::ConnectionBad:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?
如果我将此行添加到database.yml:
host: localhost
Run Code Online (Sandbox Code Playgroud)
并再次运行迁移,我看到这个错误:
耙子中止!PG::ConnectionBad:无法连接到服务器:连接被拒绝 服务器是否在主机“localhost”(127.0.0.1) 上运行并接受端口 5432 上的 TCP/IP 连接?
如何解决?
Atu*_*uri 13
似乎没有为您的应用程序提供数据库,您需要添加一个:
heroku addons:create heroku-postgresql
Run Code Online (Sandbox Code Playgroud)
您可以通过运行以下命令来验证数据库是否已添加到您的应用程序中:
heroku config --app your_app_name
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2823 次 |
| 最近记录: |