Having trouble connecting QGIS with postgres database with postgis extension

by Carl Carlson   Last Updated April 13, 2015 00:09 AM

I am working on Ubuntu Precise with postgresql version 9.3 and postgis 2.0.

After initially starting my postgres database and eventually getting permission errors that would prevent postgres from starting due to my modifying the pg_hba.conf file I followed a tutorial from ArchLinux ArchLinux postgres setupwhich stated to create a directory to house my database cluster. Previously I did not do so and had less trouble connecting to QGIS. I know postgres out of the box comes with a default database cluster, so I am wondering if I am attempting to connect to the wrong cluster?

I have config files in two different directories as a result of the tutorial I followed: *with root user: /etc/postgresql/9.3/main *under postgres (default auto-created linux user): /var/lib/postgres/data

In any case after making my modifications I also restarted my postgres server and every time I start my server I do so from etc/init.d/postgresql. If so, how exactly do I go about fixing that without breaking my postgres installation?

My error is connection refused, but my port(5432) is listening when I checked with telnet. I am trying to connect with the add Postgis layer GUI option in QGIS Dufour installed on a windows box.

*my pg_hba entry is host all all 0.0.0.0/0 md5 *local_addresses was set to * in postgresql.conf

When I tried to connect on my database server via its local in the postgres user I tried psql -h 127.0.0.1 -U postgres -d postgres

...and I got "could not connect to server, etc", which leads me to believe the loopback is failing because wildcard should allow localhost as well.

Are you supposed to be able to connect to the server on a local machine or...? Do I have to change my iptables default settings?

*No particular errors on my postgresql installation stuck out.



Answers 1


I think I understand why it isn't working for you, I had this problem some time ago. Although you installed the database with the postgis extension try the "create extension postgis" before connecting to that database. This is why it gives you an error when it tries to do the "select postgis_version()" function. In conclusion, try and connect to a database that has postgis extension enabled.

tudorbarascu
tudorbarascu
October 24, 2013 04:45 AM

Related Questions


Updated July 19, 2017 12:22 PM

Updated March 24, 2019 15:22 PM

Updated March 15, 2017 12:22 PM

Updated April 21, 2017 09:22 AM