how to connect pgadmin container to localhost postgres

I pulled pgAdmin4 docker image into my linux debian machine and followed the process specified here to configure the container. I run docker run -p 8000:8000 --env-file ./pgadmin_docker_env.list -d dpage/pgadmin4. For clarity, the pgadmin_docker_env.list specified in the command contains the environmental variables:: [email protected] PGADMIN_DEFAULT_PASSWORD=my_password. With the container running in detached mode, I run localhost:8080 in my web browser to access pgAdmin 4 in server mode. However, I was unable to create a server connection to the localhost postgres database from inside the pgadmin. I got the following error after input of the connection parameters (shown in the screenshot attached below)
enter image description here
Unable to connect to server: connection to server at "localhost" (, port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

I used host.docker.internal in place of localhost but I still got an error

Unable to connect to server: could not translate host name "host.docker.internal" to address: Name does not resolve

Source: Docker Questions