简体   繁体   English

第一个Heroku,Ruby和Postgres应用-本地Postgres错误

[英]First Heroku, Ruby & Postgres App - Local Postgres Error

I have been following Heroku's guide to getting started with Ruby on Heroku, and have gotten stuck trying to connect to the postgres database. 我一直在遵循Heroku的Heroku上的Ruby入门指南,并且一直试图连接到postgres数据库而陷入困境。

When I run: 当我跑步时:

bundle exec rake db:create db:migrate

I am left with this error: 我留下了这个错误:

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

And: 和:

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"garrett", "username"=>"ruby-getting-started"}
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I have tried editing my database.yml file but I'm not sure if I am changing the correct parameters: 我尝试编辑database.yml文件,但是不确定是否要更改正确的参数:

default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5

development:
<<: *default
database: ruby-getting-started_development
username: ruby-getting-started

test:
<<: *default
database: ruby-getting-started_test

production:
<<: *default
database: ruby-getting-started_production
username: ruby-getting-started
password: <%= ENV['RUBY-GETTING-STARTED_DATABASE_PASSWORD'] %>

Do I have my database.yml setup incorrectly or am I completely wrong? 我的database.yml设置是否错误或完全错误?

This is a common Postgres error that is basically telling you it can't find the server. 这是一个常见的Postgres错误,基本上是在告诉您找不到服务器。 This can be caused by various reasons from not having it installed to a broken path from an OS update. 这可能是由于各种原因导致的,从未安装到OS更新的路径断开。

If you do have the server installed you could re install it through Homebrew or the GUI windows installer found at postgres.org. 如果确实安装了服务器,则可以通过Homebrew或postgres.org上的GUI Windows安装程序重新安装它。

Either way the fastest fix is to use a single package installer like Postgres.app for mac. 无论哪种方式,最快的解决方法都是使用Mac的Postgres.app之类的单个软件包安装程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM