I am trying to set up a database on my computer that can be accessed remotely by others. I have modified my postgresql.conf by to listening_addresses = '*'
and added host all all 0.0.0.0/0 md5
to my pg_hba.conf file. When we try to connect to the database remotely, we get the error psql: could not connect to server: Connection refused Is the server running on host "MYIPADDRESS" and accepting CP/IP connections on port 5432?
The port is 5432 is also closed when I got to https://www.yougetsignal.com/tools/open-ports/ . How do we go about solving this problem? Let me know if I need to provide more code. Thanks in advance!
Update: Here is my log.
2020-06-01 12:00:09.385 EDT [13570] LOG: listening on IPv6 address "::1", port 5432
2020-06-01 12:00:09.385 EDT [13570] LOG: listening on IPv4 address "127.0.0.1", port 5432
2020-06-01 12:00:09.386 EDT [13570] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Are you sure so your database is running?
Do you see Postgres is process list? ps ax|grep postgres
.
Do you see some interesting in Postgres log?
Postgres log should to contains:
serverlog [----] 0 L:[ 1+ 0 1/589] *(0 /50295b) 0050 0x032 [*][X] 2020-05-29 07:45:11.931 CEST [12960] LOG: starting PostgreSQL 13beta1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.1.1 20200507 (Red Hat 10.1.1-1), 64-bit 2020-05-29 07:45:11.933 CEST [12960] LOG: listening on IPv6 address "::1", port 5432 2020-05-29 07:45:11.933 CEST [12960] LOG: listening on IPv4 address "127.0.0.1", port 5432 2020-05-29 07:45:11.959 CEST [12960] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
If Postgres is running, then problem can be firewall. You should to open port 5432 for remote access.
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.