
HerokuでWEBアプリを公開したときにつまづいた箇所と対応方法
1.”heroku pg:info”
事象
コマンドプロンプトで”heroku pg:info”を実行したところ、以下メッセージが表示される
» Warning: heroku update available from
» 7.53.0 to 8.1.9.
! postgresql-deep-89401 is not
! yet provisioned.
! Run heroku addons:wait
! to wait until the db is provisioned.
対策
"heroku update"を実行
2."heroku pg:psql -c "\d""
事象
コマンドプロンプトで"heroku pg:psql -c "\d""を実行したところ、エラーメッセージが表示される
対策
Pathを設定する
(参考)https://qiita.com/Puerto/items/5b886d0ed202761c4cc1
3.DBアクセスでエラー
事象
DBアクセスする処理(ログイン)実行時に以下エラー

ログは以下
2023-08-04T04:45:33.128348+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/authenticate" host=hidden-refuge-17323-f5f81ab10ce5.herokuapp.com request_id=c3c29dc4-4234-42e7-b38f-0add8d8184ff fwd="130.62.23.91" dyno=web.1 connect=0ms service=16ms status=503 bytes=0 protocol=https
2023-08-04T04:45:33.266535+00:00 heroku[web.1]: Process exited with status 1
2023-08-04T04:45:33.313490+00:00 heroku[web.1]: State changed from up to crashed
2023-08-04T04:45:38.525704+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hidden-refuge-17323-f5f81ab10ce5.herokuapp.com request_id=0b644f50-c9c7-40aa-a35e-1c7ff980ff8c fwd="130.62.23.91" dyno=web.1 connect=5001ms service= status=503 bytes= protocol=https
Restarting hidden-refuge-17323 dynos on ⬢ pp... !
! Couldn't find that app.
原因
ログイン処理で存在しないユーザーを入力していたのでエラーハンドリングに入っていた。
対策
エラーハンドリングの"log.Fatalln(err)"を"log.Println(err)"に変更。
Fatallnはプロセスを終了するので、終了させたくない(どこかにリダイレクトさせるとか)場合は使わないほうが良い。
(参考)https://qiita.com/neko_the_shadow/items/70642e57723d42b8514c