Why can't the PostgreSQL database be accessed from the external network? Where is the problem?
I want to verify if the PostgreSQL I created can be accessed through an external network. I used the
telnet host port
command in PowerShell to test if the host can be connected, then used the Ctrl+]
command and entered status
. The screen shows that it is connected, but after about a minute, it shows that the connection is lost.
When I use pgAdmin to connect to my database, it keeps failing and shows "connection timeout expired". However, if I use psql -U myusername -d dbname
inside the container, I can enter the database normally and use various commands.
In other words, it works normally inside the container but not from the outside.
Where could the problem be? I am sure I have opened external port 5432.

6 Replies
@ningshen what value are you using in your hostname? your domain or your ip?
i used my domain
Use your ip instead
After reading your reply, I tried to log in with the host IP again, and now I can log in successfully
thank you , brother😍
If you are using an internal host, should you replace it with 127.0.0.1 as well ?
No, in that case you should use the internal host
well,thanks 😀