简体   繁体   中英

Rails PG Unix domain socket “/tmp/.s.PGSQL.5432”? issue

I have uninstalled and installed PG and all the pg related gems. When i try to run the rails server i am getting the following error

rails s
=> Booting WEBrick
=> Rails 4.2.5.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-03-02 22:23:01] INFO  WEBrick 1.3.1
[2016-03-02 22:23:01] INFO  ruby 2.2.2 (2015-04-13) [x86_64-darwin14]
[2016-03-02 22:23:01] INFO  WEBrick::HTTPServer#start: pid=6351 port=3000


Started GET "/" for ::1 at 2016-03-02 22:23:06 +0530

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 (4.2.5.2) lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
  /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
  /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
  activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
  activerecord (4.2.5.2) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
  activerecord (4.2.5.2) lib/active_record/connection_handling.rb:87:in `connection'
  activerecord (4.2.5.2) lib/active_record/migration.rb:383:in `connection'
  activerecord (4.2.5.2) lib/active_record/migration.rb:370:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.5.2) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
  activesupport (4.2.5.2) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  activesupport (4.2.5.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack-contrib (1.4.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.4.0) lib/meta_request/middlewares/headers.rb:16:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (4.2.5.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5.2) lib/rails/rack/logger.rb:20:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activesupport (4.2.5.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (4.2.5.2) lib/action_dispatch/middleware/static.rb:116:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (4.2.5.2) lib/rails/engine.rb:518:in `call'
  railties (4.2.5.2) lib/rails/application.rb:165:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'



Started POST "/__better_errors/6febe33a854ba104/variables" for ::1 at 2016-03-02 22:23:06 +0530

The server.log in postgres shows the following

DETAIL:  Permissions should be u=rwx (0700).
FATAL:  data directory "/usr/local/var/postgres" has group or world access
DETAIL:  Permissions should be u=rwx (0700).
FATAL:  data directory "/usr/local/var/postgres" has group or world access
DETAIL:  Permissions should be u=rwx (0700).
FATAL:  data directory "/usr/local/var/postgres" has group or world access
DETAIL:  Permissions should be u=rwx (0700).
FATAL:  data directory "/usr/local/var/postgres" has group or world access
DETAIL:  Permissions should be u=rwx (0700).

On restarting the brew services

➜  postgres git:(master) brew services postgres restart
==> Tapping homebrew/services
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 7 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
Checking connectivity... done.
Tapped 0 formulae (32 files, 42.0K)
Error: No available formula with the name "restart"

This error usually comes when postgres server is not up. Try restarting postgres service. You can restart postgres using command:

sudo service postgresql restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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