关于ruby on rails:更新到最新OS X后的Postgres错误

Postgres Error after updating to Latest OS X

嘿家伙我最近更新了我的mac到最新的OS X 10.12.3
以前我的rails项目工作正常,现在每当我启动我的rails服务器时,我的项目都会出现此错误。 我在stackoverflow中尝试了很多不同的解决方案,它仍然无法正常工作。

以下是我尝试过的一些内容

Postgres无法连接到服务器

PostgreSQL错误'无法连接到服务器:没有这样的文件或目录'

谢谢,请帮帮我

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
PG::ConnectionBad (could NOT CONNECT TO server: No such file OR directory
    IS the server running locally AND accepting
    connections ON Unix DOMAIN socket"/tmp/.s.PGSQL.5432"?
):

activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:671:IN `initialize'
activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `
NEW'
activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `connect'

activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:217:IN `initialize'
activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `
NEW'
activerecord (5.0.0.1) lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'

activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:721:IN `new_connection'
activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in `
checkout_new_connection'
activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in `try_to_checkout_new_connection'

activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:705:IN `acquire_connection'
activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in `
checkout'
activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'

activerecord (5.0.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:875:IN `retrieve_connection'
activerecord (5.0.0.1) lib/active_record/connection_handling.rb:128:in `
retrieve_connection'
activerecord (5.0.0.1) lib/active_record/connection_handling.rb:91:in `connection'

activerecord (5.0.0.1) lib/active_record/migration.rb:558:IN `connection'
activerecord (5.0.0.1) lib/active_record/migration.rb:545:in `
CALL'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'

activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:IN `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `
_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'

actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:IN `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `
CALL'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'

actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:IN `call'
web-console (3.3.1) lib/web_console/middleware.rb:131:in `
call_app'
web-console (3.3.1) lib/web_console/middleware.rb:28:in `block in call'

web-console (3.3.1) lib/web_console/middleware.rb:18:IN `catch'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `
CALL'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'

railties (5.0.0.1) lib/rails/rack/logger.rb:36:IN `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `
block IN CALL'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'

activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:IN `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `
tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'

sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:IN `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `
CALL'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'

rack (2.0.1) lib/rack/runtime.rb:22:IN `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `
CALL'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'

actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:IN `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `
CALL'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'

rack (2.0.1) lib/rack/handler/webrick.rb:86:IN `service'
/Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `
service'
/Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'

/Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/server.rb:296:IN `block in start_thread'
  Rendering /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  Rendering /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (5.0ms)
  Rendering /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.2ms)
  Rendering /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.7ms)
  Rendered /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (98.5ms)
[2017-02-01 15:42:00] ERROR PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket"/tmp/.s.PGSQL.5432"?

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `
initialize'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `new'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:IN `connect'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `
initialize'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `new'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:IN `postgresql_connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in `
new_connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in `checkout_new_connection'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:IN `try_to_checkout_new_connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `
acquire_connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in `checkout'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:IN `connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in `
retrieve_connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:128:in `retrieve_connection'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:91:IN `connection'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/query_cache.rb:47:in `
block IN install_executor_hooks'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:396:in `instance_exec'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:396:IN `block in make_lambda'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:169:in `
block (2 levels) IN halting'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:547:in `block (2 levels) in default_terminator'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:546:IN `catch'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:546:in `
block IN default_terminator'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:170:in `block in halting'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:454:IN `block in call'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:454:in `
each'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:454:in `call'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:101:IN `__run_callbacks__'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `
_run_complete_callbacks'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/execution_wrapper.rb:107:IN `complete!'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/executor.rb:13:in `
block IN CALL'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/body_proxy.rb:23:in `close'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/handler/webrick.rb:115:IN `service'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `
service'
    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'

    /Users/leo/.rbenv/versions/2.3.2/lib/ruby/2.3.0/webrick/server.rb:296:IN `block in start_thread'


尝试使用此命令启动postgres服务器:

1
pg_ctl -D /usr/LOCAL/var/postgres -l /usr/LOCAL/var/postgres/server.log START

我找到了解决方案。 只需下载postgres应用程序

http://postgresapp.com/

不确定它是否适用于所有人,但它对我有用:)