昨日までは何事もなくこのアプリケーションにアクセスできていましたが、急にエラーが出るようになりました。
すでに自分でも検索しながら4hほど奮闘しているのですが改善の兆しが見えません。参考にしたURL->
http://stackoverflow.com/questions/19828385/pgconnectionbad-could-not-connect-to-server-connection-refused
そして検索しながら気になる点が2点見つかりました。
- postmaster.pidを消す -> しかしpostmaster.pidが見つかりません..
- 自分だけディレクトリの場所がおかしい気がする..
- server.logを確認したいが方法がわかりません..
$ bundle exec rails db:create WARNING: Nokogiri was built against LibXML version 2.9.4, but has dynamically loaded 2.9.2 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? Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "username"=>"user", "password"=>"****", "host"=>"localhost", "port"=>5432, "database"=>sample_development"} rails aborted! PG::ConnectionBad: 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? /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `initialize' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `new' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `connect' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `initialize' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `new' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in `new_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in `checkout_new_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in `try_to_checkout_new_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `acquire_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in `checkout' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:877:in `retrieve_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_handling.rb:128:in `retrieve_connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/connection_handling.rb:91:in `connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/postgresql_database_tasks.rb:6:in `connection' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/postgresql_database_tasks.rb:15:in `create' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:109:in `create' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:129:in `block in create_current' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:292:in `block in each_current_configuration' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:291:in `each' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:291:in `each_current_configuration' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:128:in `create_current' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/railties/databases.rake:27:in `block (2 levels) in <top (required)>' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/commands_tasks.rb:51:in `run_command!' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands.rb:18:in `<top (required)>' /Users/ponta/sample/bin/rails:9:in `require' /Users/ponta/sample/bin/rails:9:in `<top (required)>' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `load' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `call' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/client/command.rb:7:in `call' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/client.rb:30:in `run' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/bin/spring:49:in `<top (required)>' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `load' /Users/ponta/.rvm/gems/ruby-2.3.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `<top (required)>' /Users/ponta/sample/bin/spring:13:in `require' /Users/ponta/sample/bin/spring:13:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace)
default: &default adapter: postgresql encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: user password: '******' host: localhost port: 5432 development: <<: *default database: sample_development test: <<: *default database:sample_test production: <<: *default database: sample_production username: sample password: <%= ENV[SAMPLE_DATABASE_PASSWORD'] %>
$ which psql /usr/local/bin/psql
$ which postgres /usr/local/bin/postgres
$ psql psql: 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"?
/usr/local/var/postgres/server.log postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": No such file or directory =>postgresql.logを手動で作成しました。 作成した後のログ => LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf" FATAL: data directory "/usr/local/var/postgres" has wrong ownership HINT: The server must be started by the user that owns the data directory.
$ initdb /usr/local/var/postgres -E utf8 The files belonging to this database system will be owned by user "ponta". This user must also own the server process. The database cluster will be initialized with locale "ja_JP.UTF-8". initdb: could not find suitable text search configuration for locale "ja_JP.UTF-8" The default text search configuration will be set to "simple". Data page checksums are disabled. initdb: directory "/usr/local/var/postgres" exists but is not empty If you want to create a new database system, either remove or empty the directory "/usr/local/var/postgres" or run initdb with an argument other than "/usr/local/var/postgres".
拙い質問となってしまい申し訳ありません、わかる方いましたらお手数ですが教えてくださいませ。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。