简体   繁体   中英

postgres doesnt restart after making the necessary .conf file changes

apologies first. On a steep learning curve more like a wall and will be verbose and lacking in jargon but too old to change that now. I'm trying to access a Postgresql-13 (with postgis-3 extensions) database from a machine other than the one where it is hosted. Before doing anything at all other than install, create and consume a spatial data file, this is the partial screen dump from

sudo netstat -ltpn

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 993/postgres

... and the database is accessible from pgadmin4 on the Ubuntu 20.04 machine which is hosting it. I can also connect to the database in QGIS on the same Ubuntu machine through 127.0.0.1 and port 5432. Nothing special about that other than knowing it works. What I want to do is connect to that database from any machine running QGIS (or another GIS platform which can consume postgis).

Port forwarding rules on the router are set for 80, 8080 and 5900 to point to 10.0.0.55 which is the IP for the Ubuntu 20.04 which is hosting. I have a dynamic DNS pointing the routers IP to give it the name http://blah.blah.net (not actually that, but close).

pgadmin4 is installed and configured to run in server and I can access the database through pgadmin4 from the host or any other computer using http://blah.blah.net/pgadmin4 . Not sure I got this config quite right but it works. Geoserver is also running smoothly on Tomcat9 accessible from anywhere through http://blah.blah.net:8080/Geoserver/web/ . And a fancy front end in the making on http://blah.blah.net .

Have then done the following mods to the two.conf files in etc/postgresql/13/main which are well noted and documented already...

host all all 0.0.0.0/0 md5

in the pg_hba.conf

and also...

listen_addresses='*' (and removed the leading #)

port = 5432 (was already)

in the postgresql.conf

Then restarted postgres with...

sudo service postgresql restart

... and then port 5432 disappears completely and the database is not accessible from anywhere. Not even the host computer. Checked that postgresql was running with...

sudo systemctl status postgresql

... which it appears to be. But am getting nothing from QGIS or pgadmin4. Not even from the host machine.

Got a lot of questions but the most obvious is am I missing something? Not sure if I need a rule at the router for port 5432 - did try that in a similar fashion to the rules above but it didn't change anything. Appreciate any help. Cheers... R

The local address in the netstat output:

127.0.0.1:5432

indicates that PostgreSQL is only listening on the loopback interface. Since you changed listen_addresses in postgresql.conf , I conclude that you forgot to restart PostgreSQL.

To confirm, run this query:

SELECT setting, pending_restart
FROM pg_settings
WHERE name = 'listen_addresses';

It should either show the wrong value (if you didn't reload or changed the wrong file altogether) or show pending_restart as TRUE (if you reloaded, but didn't restart).

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