vercel / vercel/examples

PostgreSQL on docker and Next.js locally Error: connect ECONNREFUSED ::1:443

Open
#850 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.2k
Forks
1.8k
Avg merge
3d 12h
Merged PRs (30d)
6

Description

Hi, I'am trying to follow this tutorial

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

and I'am using @vercel/postgres. Instead to open a remote DB on Vercel I wanto to use a docker image of postgresDB and connect to it. This is my setup:

.env

# Copy from .env.local on the Vercel dashboard
# https://nextjs.org/learn/dashboard-app/setting-up-your-database#create-a-postgres-database
POSTGRES_URL="postgres://postgres:postgres@localhost:5432/postgres"
POSTGRES_PRISMA_URL="postgres://postgres:postgres@localhost:5432/postgres"
POSTGRES_URL_NON_POOLING="postgres://postgres:postgres@localhost:5432/postgres"
POSTGRES_USER="postgres"
POSTGRES_HOST="localhost"
POSTGRES_PASSWORD="postgres"
POSTGRES_DATABASE="postgres"

docker-compose.yml

version: "3.8"

services:
  db:
    container_name: db
    image: postgres:15
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    ports:
      - 5432:5432
    volumes:
      - pgdata:/var/lib/postgresql/data

  pgadmin:
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: "admin@admin.com"
      PGADMIN_DEFAULT_PASSWORD: "admin"
    ports:
      - "80:80"
    depends_on:
      - db

volumes:
  pgdata: {}

and my seed file like in tutorial:

https://github.com/vercel/next-learn/blob/main/dashboard/starter-example/scripts/seed.js

the error when I run node -r dotenv/config ./scripts/seed.js is:

 Error: connect ECONNREFUSED ::1:443
        at createConnectionError (node:net:1634:14)
        at afterConnectMultiple (node:net:1664:40) {
      errno: -61,
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '::1',
      port: 443
    },

Is @vercel/postgres able to connect locally? How can I work locally on my mac without open a remote Database on Vercel.

Additional note: I'am able to connect with other GUI client like TablePlus or AceSql o PGAdmin so my postgress DB docker container is correctly up and running.

Any ideas how to solve?

Thx all

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 with scripts/seed.js and the .env values shown in the issue, then compare them with the nextjs.org database setup tutorial and the docker-compose.yml service configuration. Run node -r dotenv/config ./scripts/seed.js while checking the reported connection target; done means the seed script connects to the local PostgreSQL container without the ECONNREFUSED error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript, nextjs, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.