My node.js can't establish connection to Ppostgres in docker

I created a web app to display data and im using postgres to store the data.

I created a container for postgres and pgadmin4 each. I created a server in pgadmin and connected it to the postgres container with this following info: user: ‘postgres’, password: ‘postgresmaster’, host: ‘172.17.0.2’, ‘database: recent’. I’ve configured this info when setting up the postgres container. the host is the IP address of the postgres container.

When I run the node.js file with those configurations and try to run my web app, I get an error:
image

How can i establish the connection? thanks for the help