0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

postgresqlに接続するとSSLが有効になってないため弾かれる場合の対処方法

Posted at

はじめに

golang-migratepostgresqlに接続してmigrateを試みたところ、以下のエラーが発生した。

調べたところ、postgresコンテナーがデフォルトで SSL を有効にしないために起こるとのことだったので対処方法をまとめる。

migrate -path db/migration -database "postgresql://username:password@localhost:5432/dbname" -verbose up
2022/10/30 17:19:16 error: pq: SSL is not enabled on the server

対処方法

?sslmode=disableをデータベースURLに追加することで接続が可能になります

migrate -path db/migration -database "postgresql://username:password@localhost:5432/dbname?sslmode=disable" -verbose up

2022/10/30 17:21:06 Start buffering 1/u init_schema
2022/10/30 17:21:06 Read and execute 1/u init_schema
2022/10/30 17:21:06 Finished 1/u init_schema (read 9.189788ms, ran 32.894114ms)
2022/10/30 17:21:06 Finished after 50.370077ms
2022/10/30 17:21:06 Closing source and database
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?