简体   繁体   中英

Why connection to postgres from nodejs is not working?

I have back-end created in nodejs hosted on Debian server using postgres 14. the Nodejs listenning on port 5000, and when I try to connect to postgres using port 5432, I am getting the following reponse from Postman: "Password is invalid". I was trying the postgres role, and to create a new role, and problem is the same. I was installing postgres on my Windows 10 computer, and all works fine in my localhost, but on the remote server not. My Nodejs back-end, and postgres are on the same computer, but each role I've tryed won't connect to the database.

There is pg_hba.conf in /etc/postgres/14 on your server you have to add:

host username database 0.0.0.0/0 md5

This would allow connection to database from any host to username using password authentication.

Also there is a pg.conf or postgres conf There is line allow_connections the value should be '*'

allow_connections='*'

This would generally allow connections to postgres running on that server

Guide https://coderwall.com/p/cr2a1a/allowing-remote-connections-to-your-postgresql-vps-installation

don't forget you have to reload postgres after config change:

systemctl reload postgres

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM