railsのエラーと解決手順のメモです。
環境
- macOS bigsur
- ruby 2.6.6p146
- Rails 6.1.3
brew info postgresql-> postgresql: stable 13.1
作業ログ
rails new myapp --database=postgresql をして、 rails s をするとエラーが出た;
ActiveRecord::ConnectionNotEstablished (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"?
):
略
この記事通り以下のコマンドを実行したら、治ったのかはわからないが、少なくともエラーメッセージは変わった;
brew services start postgresql brew services stop postgresql brew services restart postgresql
もう一度 rails s をしたら、別のエラーメッセージが出た;
ActiveRecord::NoDatabaseError (FATAL: database "deepl_helper_development" does not exist ): 略
この記事通り以下のコマンドを実行したら、エラーはもう出なくなった;
rails db:create
http://127.0.0.1:3000 にアクセスするとちゃんとrailsの初期ページが表示された。