这是我第一次使用postgresql。我已经检查过,服务器似乎肯定正在运行,但是当我启动工头时我收到了这个错误
[...]postgresql_adapter.rb:1206:in `initialize': could not connect to server: No such file or directory (PG::Error)
任何想法出了什么问题?
由于
更新:
我打开了pgAdmin,db设置为侦听端口8000而不是5432(这似乎是rails想要的)。我尝试创建一个新连接并将其设置为5432,但我收到此错误:
服务器不听
服务器不接受连接:连接库报告
could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (fe80::1) and accepting TCP/IP connections on port 5432?
答案 0 :(得分:1)
我通过修改database.yml
文件让Foreman再次工作。我不得不将端口更改为8000
(postgres正在监听)。
答案 1 :(得分:0)
更改端口对我不起作用。我使用Postgres.app
在Mac上安装了postgres我必须更新Rails数据库配置(database.yml)以添加主机字段并将其设置为localhost并删除用户名和密码字段
development:
adapter: postgresql
encoding: unicode
database: project_development
host: localhost
pool: 5
修复错误后,我所连接的数据库不存在。要解决此问题,请使用psql连接到postgres并创建数据库
CREATE DATABASE project_development;
将DB名称替换为您的案例的正确名称。
Postgres.app文档还提供了在其他环境中配置的其他信息 http://postgresapp.com/documentation#toc_3