Migrate dev fails
See original GitHub issueBug description
Hello I am following this NestJS + Prisma / PostgreSQL tutorial until this command fails :
npx prisma migrate dev --name init --preview-feature
ā¦ using this env variable :
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/testdb?schema=public"
results in :
Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Datasource ādbā: PostgreSQL database ātestdbā, schema āpublicā at ālocalhost:5432ā Error: P1001: Canāt reach database server at
localhost
:5432
Please make sure your database server is running atlocalhost
:5432
. ā¦
I tried with other ORMs, pg
and vanilla psql createdb
without issue, using same connection string.
i also tried modifying pg_hba.conf
to allow local and host for all with trust method, without success ā¦
Expected behavior
I expect Prisma to connect properly, like with Sequelize/Typeorm/pg/psql ā¦ and create the database testdb
.
Environment & setup
- OS: Windows 10.0.19042
- Database: PostgreSQL 13.1 (freshly installed from scratch)
- Node.js version: 15.5.0
- Prisma version: using
npx prisma
so latest 2.13.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
@Sharlaan, I could be mistaken about this (and would love clarification if I am wrong), but I donāt believe that the migrate command creates the initial database.
Also, the tutorial you linked is using SQLite, which doesnāt require anything except a file (donāt quote me on that, but it is much simpler). You might note in the expanded section on MySQL/Postgres, they reference the process for creating a database.
When I have set this up on my end, I had to create the database myself. To be honest, Iād love it if the tool would take care of creation for me (one less thing to document), but I donāt think it does.
I had the same issue and solved it by manually creating the database, as the migrate command doesnāt do it. Thanks for the tip @jthn.
I think this issue should be reoppened, as the prisma error message is wrong and misleading: āError: P1001: Canāt reach database server at localhost:5432ā should rather be āError: non-existent database āmydbāā.