LoginSignup
0
0

PostgreSQLでprisma migrateがError: P1010: User `username` was denied access on the databaseで失敗する

Last updated at Posted at 2024-01-17

問題

Dockerコンテナ上にPostgreSQLを構築し、prismaでmigrateを実行しようとしたら以下のようなエラーになった。

$ prisma migrate dev
Error: P1010: User `username` was denied access on the database `hoge-db.public`

usernameという名前のユーザーはちゃんと存在していて、権限を確認したところ問題なさそうだった。
Prismaの接続設定も問題なさそうだった。

原因

色々探った結果、ローカルマシンに同ポートでPostgreSQLが起動していたのが原因だった。

$ ps aux | grep postgres
// 省略
hoge 6066   0.0  0.0 408843216   7568   ??  S    11:27PM   0:00.04 /opt/homebrew/opt/postgresql@15/bin/postgres -D /opt/homebrew/var/postgresql@15
hoge 8642   0.0  0.0 408626896   1360 s008  S+   11:33PM   0:00.00 grep postgres

まとめ

ローカルマシンとDockerコンテナ間でポートが競合すると、予期しないエラーが発生するので気をつけましょう。

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