LoginSignup
26
21

More than 3 years have passed since last update.

【Rails】「heroku run rake db:migrate」を実行しようとすると発生するエラーについて

Last updated at Posted at 2018-12-02

エラーコード

rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

database.ymlをいろいろいじったり、Gemfileを触ってみてもうまく行かない、、、。

と、こんな質問を見つける。

どうやらアドオンを入れなければいけない、、、?

とりあえず実行してみるよ。

$ heroku addons:create heroku-postgresql

Creating heroku-postgresql on ⬢ polar-retreat-48576... free
Database has been created and is available
 ! This database is empty. If upgrading, you can transfer
 ! data from another database with pg:copy
Created postgresql-graceful-23460 as DATABASE_URL
Use heroku addons:docs heroku-postgresql to view documentation

からの

$ heroku run rails db:migrate

なぜか成功!

理由はよくわからないけど、おそらくdatabase.ymlのproductionのをこうやって書いているからだと思う?

ただ単に、herokuでpostgresを使う際にアドオンが必要なだけですね、これ。

database.yml
production:
  url: <%= ENV['DATABASE_URL'] %>

と思ったら、heroku上でうまく動いていない、、、(サインアップしようとするとエラー発生)。

$ heroku[router]: at=info method=POST path="/users" host=polar-retreat-48576.herokuapp.com request_id=41dae68e-9bc7-44f3-b0de-198bb81f4c6d fwd="180.235.55.101" dyno=web.1 connect=0ms service=228ms status=500 bytes=1827 protocol=https

エラーコードはこれですね。

スクリーンショット 2018-12-02 18.00.36.png

調べたところ、ログインに使っている”devise”というgemでメールを送るのに設定が必要だった。

ということで、以下の記事を読んで設定をする。

これでやっと動きました。お疲れ様でした!!

ちなみに、エラーは、”rails_12factor”というgemを入れて特定しました。以下の記事で紹介されています。

26
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
21