vercel / vercel/next-learn

Chapter 6: unable to connect to postgres database

Open
#1,306 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.8k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

Before submitting
  • I have searched existing issues to make sure this isn't a duplicate
  • I have completed this chapter and encountered the issue myself
Chapter URL

https://nextjs.org/learn/dashboard-app/setting-up-your-database#executing-queries

Issue Type

Build or runtime error

Description

have the following problem:
Seed the database by running:
http://localhost:3000/seed
I am getting a:
GET /seed 500 in 21ms (compile: 4ms, render: 17ms)

And in the prosgresql log:
LOG: invalid length of startup packet

I found in the package.json that bcrypt still exists.

{
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev --turbopack",
"start": "next start"
},
"dependencies": {
"@heroicons/react": "^2.2.0",
"@tailwindcss/forms": "^0.5.10",
"autoprefixer": "10.4.20",
"bcrypt": "^5.1.1",
"bcryptjs": "^3.0.3",
"clsx": "^2.1.1",
"next": "latest",
"next-auth": "5.0.0-beta.25",
"postcss": "8.5.1",
"postgres": "^3.4.6",
"react": "latest",
"react-dom": "latest",
"tailwindcss": "3.4.17",
"typescript": "5.7.3",
"use-debounce": "^10.0.4",
"zod": "^3.25.17"
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/node": "22.10.7",
"@types/react": "19.0.7",
"@types/react-dom": "19.0.3"
},
"pnpm": {
"onlyBuiltDependencies": [
"bcrypt",
"sharp"
]
}
}
my .env file:

POSTGRES_URL="postgresql://user:password@localhost:5432/nextjs_dashboard"

Even the change:

POSTGRES_URL="postgres://user:password@localhost:5432/nextjs_dashboard"
GET /seed 500 in 54ms (compile: 33ms, render: 21ms)
LOG: invalid length of startup packet

I can connect to the database with pgadmin and the specific user/ password.

Hopefully someone can help me out?

On forhand thank you for your help!

Expected vs Actual Behavior

Unable to connect with postgres database

Environment (optional)

No response

Screenshots (optional)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the chapter's GET /seed entry point and inspect the database setup plus package.json and POSTGRES_URL configuration. Reproduce the request while checking the PostgreSQL log; done means the seed request completes without a 500 and the database is populated.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.