I've setup a local installation of PostGIS in the past, and had no problem connecting QGIS to it in Localhost. However, I recently rented an Amazon Lightsail Ubuntu virtual machine to make my PostGIS database available remotely, and I can't figure out how to connect QGIS to it.
Possible problem #1: One of the big differences I noticed between installing PostgreSQL/PostGIS locally with the installer (from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads), and with the command lines (apt-get install postgresql postgresql-contrib
and apt-get install postgis
) is that, with the former, the installer asked me for a 'postgres' superuser password, and no password was asked to me in command line. Hence, when I try to connect to PostGIS in QGIS, the password part is a mystery.
I therefor looked at how to setup a password with the command \password
and restarted the server, but QGIS still can't connect:
Possible problem #2:
I looked for a solution and found this answer : https://stackoverflow.com/questions/38466190/cant-connect-to-postgresql-on-port-5432. Which suggests to modify the file postgresql.conf
and set this parameter as such: listen_addresses = '*'
.
However, I'm not sure where to find this file in my Amazon Lightsail VM. Also, this seems like a "hacky" solution. Has anyone had this kind of problems before? Is there a trick I'm overseeing? In short: what's the proper way to fix this?