Skip to main content

Connect to PostgreSQL from ArcGIS

The following list summarizes the steps required to connect from ArcGIS Server 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 and control what databases they can access, 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.

Read the PostgreSQL documentation for instructions.

Create a database connection

You must have a database connection (.sde file) that authenticates the connection to the database.

You can call the ArcPy CreateDatabaseConnection function from one of the machines in the ArcGIS Server site that needs to connect to the database. See Create Database Connection in the ArcGIS Pro help for information about running this function.

Confirm that the database name and username meet ArcGIS object name requirements

The following information is specific to creating a database connection file for use with ArcGIS Server:

  • You must save the user information with the connection file.

  • If you use operating system authentication, ensure PostgreSQL can authenticate the ArcGIS Server account.

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. If the connection uses operating system authentication and you will publish web services using this connection, ensure the ArcGIS Server account has the required privileges on the data included in the web service. See Privileges for geodatabases in PostgreSQL and Privileges for using ArcGIS with a PostgreSQL database in the ArcGIS Pro help for more information..

Register the connection file

To allow ArcGIS Server sites 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.

To register a connection using operating system authentication requires ArcGIS Enterprise 11.1 or later. The ArcGIS Server account used to run ArcGIS Server must be an SSPI or LDAP login mapped to a login role in PostgreSQL. That login role must be granted privileges to the tables to be published from the geodatabase or PostgreSQL database.