質問内容・実現したいこと
rails s
をすると下記のerrorに遭遇。
error解決までのプロセスの検索方法や解決方法をご教授いただきたいです。
よろしくお願いいたします。
環境
macbook pro 2021 ver12.01
rails -v
Rails 6.0.4.4
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin20
現状発生している問題・エラーメッセージ
bash
rails s => Booting Puma => Rails 6.0.4.4 application starting in development => Run `rails server --help` for more startup options Puma starting in single mode... * Version 4.3.10 (ruby 2.5.1-p57), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://127.0.0.1:3000 * Listening on tcp://[::1]:3000 Use Ctrl-C to stop Started GET "/" for ::1 at 2022-01-03 15:44:04 +0900 PG::ConnectionBad - connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?: Started POST "/__better_errors/24f9d00d163b738c/variables" for ::1 at 2022-01-03 15:44:04 +0900 Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default.
翻訳
PG::ConnectionBad - ソケット "/tmp/.s.PGSQL.5432" でのサーバーへの接続に失敗しました。そのようなファイルやディレクトリはありません
サーバーがローカルで動作しており、そのソケットで接続を受け入れているか?
該当のソースコード
ダウンロードされていることを確認
bash
psql -V psql (PostgreSQL) 14.1
エラーから考えられる原因
postgresql none
なので
errorの内容にある/tmp/.s.PGSQL.5432というファイルを作成する必要がある?
bash
brew services list Name Status User File postgresql none unbound none
試したこと
postgressqlの起動
bash
brew services start postgresql ==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
postgreassqlの停止
bash
brew services stop postgresql Stopping `postgresql`... (might take a while) ==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
postgressqlの起動状況の確認
bash
brew services list Name Status User File postgresql none unbound none
データベースが無いのでは?と思い rails db:create
実行しデータベースを作成するもerror
bash
$ rails db:create connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? Couldn't create 'lets_hang_out_development' database. Please check your configuration. rails aborted! PG::ConnectionBad: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace)
maigrate status を確認
bash
rails db:migrate:status rails aborted! PG::ConnectionBad: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? bin/rails:4:in `<main>'
psql 確認
bash
psql psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
参考にしたURL
まだ回答がついていません
会員登録して回答してみよう