How to connect to a PostGIS database on localhost

From Geo-How-To
Jump to: navigation, search
- Make sure PostGIS is installed. The easiest way is to use Application Stack Builder that comes with PostgreSQL.
- Usually PostgreSQL runs on localhost on port 5432, so we assume you installed it that way.

In ArcGIS

Version 10.2.x

Make sure you copied the dll-files from PostgreSQL Client Libs for the correct version of your PostgreSQL installation. They can be downloaded from Esri.


  • Go to Catalog - Add Database Connection
  • Select PostgreSQL as Database Platform
  • Fill in localhost in the Instance box (don't add the port number, because it uses the port 5432 by default and it doesn't work if you fill in localhost:5432)
  • Choose 'Database authentication' for Authentication Type.
  • Fill your User name and password
  • Select your PostGIS database from the Database drop down list.
  • Click OK

In QGIS

In version 1.9 and 2.x

  • Click on the 'Add PostGIS Layers' button. Thats the one with the elephant and the plus sign.
  • Click the New button
  • Give your connection a name so you can recognize it easily on later use.
  • Fill in localhost in the Host field.
  • Fill in 5432 in the port field
  • Fill in the name of the database you created during the installation of PostGIS in the Database field. Usually by default this is postgis or postgres, but you set this yourself during PostGIS installation.
  • Fill in the Username field with the username you created for your PostGIS installation.
  • Fill in the Password field with the password you created for your PostGIS installation.
  • Check the Save Username box.
  • Check the Save Pasword box.
  • If you click on the Test Connect button now, it should say 'Connection to [Your Database Name] was succesful'.
  • Click OK. It gives a warning about saving the password. Read it carefully and decide for yourself if you want to save the password in QGIS. The connection settings are now saved to QGIS and can now be used in other too.
  • Click Connect
  • If you have any tables in your PostGIS database, you can select it from the list and select Add or create a custom Filter.