Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not connect to postgres: error: no PostgreSQL user name specified in startup packet #922

Closed
GHCMelo opened this issue Jan 10, 2023 · 1 comment

Comments

@GHCMelo
Copy link

GHCMelo commented Jan 10, 2023

I'm getting the following error:

could not connect to postgres: error: no PostgreSQL user name specified in startup packet

When I use the following command:

node-pg-migrate up --envPath ./.env.local -m infra/migrations/

My .env.local file:

POSTGRES_USER=local_user
POSTGRES_PASSWORD=local_password
POSTGRES_DB=controle_de_gastos
POSTGRES_HOST=localhost
POSTGRES_PORT=54320
DATABASE_URL=postgres://local_user:local_password@localhost:54320/controle_de_gastos

I tried to connect to my database using DATABASE_URL string and I got success.

@Shinigami92
Copy link
Collaborator

Hi @GHCMelo,
I'm not 💯 sure, but I just searched a bit around and e.g. https://hub.docker.com/_/postgres does not show me POSTGRES_HOST and POSTGRES_PORT
Maybe these are not supported environment variables at all (out of the box)?

But with the right dotenv you maybe could achieve this by using expansions like

POSTGRES_USER=local_user
POSTGRES_PASSWORD=local_password
POSTGRES_DB=controle_de_gastos
POSTGRES_HOST=localhost
POSTGRES_PORT=54320
DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB

I'm not sure this is an issue with node-pg-migrate and as you wrote

I tried to connect to my database using DATABASE_URL string and I got success.

I think this is the way to go
So I will close this issue for now for housekeeping/maintenance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants