Prisma P1001 error: how to diagnose unreachable Postgres at localhost:5432
A developer using Prisma 6 and 7 with Postgres 17 in Docker on Windows 11 encountered the P1001 error, which reports that no connection could be made to the database server. The error message is identical regardless of cause, so the author tested five scenarios to see how the host and port changed the output. They recommend a short Node.js socket check run from the same environment as the app, whose result (such as ECONNREFUSED, ENOTFOUND, or a timeout) shows whether the problem is a stopped database, an unresolvable host, or a blocked network path. The author found that Docker port mappings often cause the mismatch, since the host-side port differs from the container port and "localhost" refers to a different machine depending on where the code runs. Starting the database and matching the port in DATABASE_URL to the one actually listening resolved the issue.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in