Skip To Content

Connect to PostgreSQL from ArcGIS

The following list summarizes the steps required to connect from ArcGIS to a PostgreSQL database, including a database that contains an enterprise geodatabase:

PostgreSQL client files are installed with ArcGIS Pro and ArcGIS Server; you do not need to install a PostgreSQL client or set environment variables to access the client.

Configure the database to allow connections

By default, only clients running on the same machine as the PostgreSQL database cluster can connect to it. To allow remote clients to connect to the database cluster, alter the PostgreSQL pg_hba.conf configuration file. The entries you place in the pg_hba.conf file will vary depending on security policies and configurations at your site.

Also, ensure the necessary login or group roles have CONNECT privileges in the database.

Complete the following steps to allow connections from clients on machines that are remote from the PostgreSQL server:

  1. Make a backup copy of the pg_hba.conf file before you alter it.
  2. Open the pg_hba.conf file in a text editor.
  3. Add the IP addresses of connecting client machines, designate the database or databases each IP address can connect to, and specify the client authentication methods used for connections.

    See the PostgreSQL documentation for more information.

  4. If PostgreSQL is installed on a Linux server, reload server configuration settings using a PostgreSQL function such as pg_ctl reload or pg_reload_conf().
  5. Ensure users have privileges to connect to the database cluster.

    By default, the Public group role has CONNECT privileges to all databases in the PostgreSQL database cluster; therefore, you only need to grant the CONNECT privilege to individual login or group roles on specific databases if you revoked the CONNECT privilege from Public.

Connect to the database

You can use the Database Connection dialog box in ArcGIS Pro to connect to the database, as described below.

Alternatively, you can run the Create Database Connection tool in ArcGIS Pro or use Python to run the Create Database Connection command from an ArcGIS Server machine to create a database connection file (.sde) that connects to the database.

To use the database connection file with ArcGIS Server, you must save the user information with the connection file.

Tip:

Ensure the account used for the connection has the appropriate privileges in the database and on the data that the account needs to access. See Privileges for geodatabases in PostgreSQL and Privileges for using ArcGIS with a PostgreSQL database for more information.

Follow these steps to connect to a PostgreSQL database from the Database Connection dialog box in ArcGIS Pro:

  1. Open the Catalog pane in ArcGIS Pro.
  2. Right-click Databases and click New Database Connection.
  3. Choose PostgreSQL from the Database Platform drop-down list.
  4. In the Instance text box, type the database cluster name or IP address of the server where PostgreSQL is installed.

    For example, if your PostgreSQL database cluster is named ficus, type ficus in the Instance text box. If specifying an IPV6 address, enclose the address in brackets. For example, if the IPV6 address of the server is 1111:aa1:0:1:f111:a222:33f3:b4bb, type [1111:aa1:0:1:f111:a222:33f3:b4bb] in the Instance text box.

    For more examples, including examples of connecting to PostgreSQL database services, see Database connections in ArcGIS Pro.

    Note:

    If your PostgreSQL database cluster is listening on a port other than the default (5432), include the port number in the instance. For example, if PostgreSQL is installed on server mamabear and is listening on port 49200, type mamabear,49200 in the Instance text box.

  5. Choose Database authentication for the Authentication Type.
  6. Provide a valid database username and password in the User name and Password text boxes, respectively.
  7. Uncheck Save user name and password if you prefer not to save your login information as part of the connection; doing this can help maintain the security of the database. However, if you do this, you will be prompted to provide a username and password every time you connect.

    Note:

    Save user name and password must be checked for connection files that provide ArcGIS web services with access to the database, or if you want to search ArcGIS Pro to locate data accessed through this connection file.

  8. Type or choose the name of the database on the PostgreSQL database cluster to which you want to connect.
  9. Click OK to create the connection file.

A database connection appears under Databases in the Catalog pane, and a connection file (.sde) is created in the ArcGIS Pro project directory.

You can rename the file by typing a new name in the Catalog pane and pressing Enter.

Register the connection with ArcGIS Server

To allow the ArcGIS Server site to access the data, use the database connection file you created to add a registered data store in ArcGIS Pro or add a data store item in the portal.