1

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: enter image description here

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?

3
1

Most likely the solution is around your possible solution #2.

If you don't modify your postgres.conf, PostgreSQL/PostGIS won't accept connections outside of localhost. If adding listen addresses = "*" to your conf seems unsafe or hacky, you can add your own IP instead, if it's somewhat static.

Here are few different options on how to locate your postgres.conf file: https://stackoverflow.com/questions/3602450/where-are-my-postgres-conf-files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.