I created a new NextJs(v14) app, installed prisma(v5.16.1) and then created a new project on Neon. I have added a .env file in my project and copied the Neon database connection string to it.
The connection string is: postgresql://[user]:[password].us-east-2.aws.neon.tech/expensedb?sslmode=require
I have added two models to the schema.primsa file. When I run "npx prisma generate" I get no erros. Afterwards, when I run "npx prisma migrate dev" I get a connection timed out error.
Error: P1001: Can't reach database server at
ep-dark-frog-a501j4x2.us-east-2.aws.neon.tech:5432
Please make sure your database server is running atep-dark-frog-a501j4x2.us-east-2.aws.neon.tech:5432
.
I tried adding connect_timeout=300 to the connection string but then the connection just hangs.
Can someone please help with this...
If possible, please recreate the steps I have taken above and see if you run into the same issue.
So after trial and error I've found a working solution.
In the neon.tech home screen, go to the "overview" tab in the sidebar and select "Roles & Databases" tab. From there, create a new Role and a new Database, and then use the new details to generate the connection string from the "Dashboard" tab in the sidebar. Following this approach, I am not getting any errors and my connection doesn't hang either. Also note, I did not need to use the "connect_timeout" parameter in the connection string.
If anyone else was having this issue, hopefully this solution works for you too.