vercel / examples

Enjoy our curated collection of examples and solutions. Use these patterns to build your own robust and scalable applications.
MIT License
3.61k stars 1.11k forks source link

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

Open davemin opened 10 months ago

davemin commented 10 months ago

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

NeuroWhAI commented 9 months ago

Related issue : #701

dx1ded commented 3 days ago

+1, how did u fix this?