To connect to PostgreSQL from ArcGIS clients, be sure PostgreSQL is configured to accept connections from your ArcGIS client machines and that the database name can be used by ArcGIS, and then you can create a database connection file in ArcGIS Pro or ArcMap.
To publish ArcGIS Server web services that reference the data in your PostgreSQL database, register the database connection file with your ArcGIS Server sites.
Connect from ArcGIS Pro
PostgreSQL client files are installed with ArcGIS Pro. To connect to a PostgreSQL database from an ArcGIS Pro project, configure the database to accept connections and create a database connection.
Configure the database to allow connections
Alter the PostgreSQL pg_hba.conf file and make sure the necessary login or group roles have CONNECT privileges in the database.
- Alter the PostgreSQL pg_hba.conf file on the database server to accept connections from the ArcGIS client machines.
- Restart PostgreSQL or force the postmaster to reload the pg_hba.conf file by running pg_ctl reload.
- Be sure users have privileges to connect to the database cluster.
By default, Public has CONNECT privileges to the PostgreSQL database cluster; therefore, you only need to grant CONNECT to individual login or group roles if you revoked the CONNECT privilege from Public.
Connect to the database
Add a database connection using the Database Connection dialog box or the Create Database Connection tool. The following steps describe using the Database Connection dialog box.
- Right-click Databases in the Catalog pane and click New Database Connection.
- Choose PostgreSQL from the Database Platform drop-down list.
- In the Data source 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 Data source 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 Data source text box.
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 Data source text box.
- Choose Database authentication for the Authentication Type.
- Provide a valid database user name and password in the User name and Password text boxes, respectively.
- 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 user name 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.
- Type or choose the name of the database on the PostgreSQL database cluster to which you want to connect.
- Click OK to connect.
Connect from ArcMap
PostgreSQL client files are installed with ArcGIS Desktop. To connect from ArcMap, configure the database to accept connections, and create a database connection from the Catalog tree in ArcMap or ArcCatalog.
Configure the database to allow connections
Alter the PostgreSQL pg_hba.conf file and make sure the necessary login or group roles have CONNECT privileges in the database.
- Alter the PostgreSQL pg_hba.conf file on the database server to accept connections from the ArcGIS client machines.
- Restart PostgreSQL or force the postmaster to reload the pg_hba.conf file by running pg_ctl reload.
- Be sure users have privileges to connect to the database cluster.
By default, Public has CONNECT privileges to the PostgreSQL database cluster; therefore, you only need to grant CONNECT to individual login or group roles if you revoked the CONNECT privilege from Public.
Connect to the database
You can connect to a database or geodatabase in PostgreSQL by adding a database connection under the Database Connections node in the Catalog tree in ArcMap or ArcCatalog.
- Expand Database Connections in the Catalog tree in ArcMap or ArcCatalog and double-click Add Database Connection.
- Choose PostgreSQL from the Database Platform drop-down list.
- 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.
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.
- Use Database authentication to connect.
- Provide the name and password of the login role with which you want to connect.
- 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 user name and password every time you connect from desktop clients.
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 Desktop to locate data accessed through this connection file.
- Type or choose the name of the database on the PostgreSQL database cluster to which you want to connect.
In the following example, user1 is connecting to database floe on the tundra PostgreSQL database cluster:
- Click OK to connect.
A file is created in \\<computer_name>\Users\<user_name>\AppData\Roaming\ESRI\Desktop<release#>\ArcCatalog.
You can move the connection to another location; just be sure users and applications that need to make a connection have read access to the directory where you place the connection file.
If you use the data from this connection as the source for a service, such as a geoprocessing or geocoding service, you may need to place the connection file in a shared location on your network. See Make your data accessible to ArcGIS Server for more information about sharing a connection file.
Connect from ArcGIS Server
ArcGIS Server includes PostgreSQL client files; therefore, you do not need to download and copy PostgreSQL client files to connect.
As with connections from other clients, be sure to alter the PostgreSQL pg_hba.conf file and make sure the necessary login or group roles have CONNECT privileges in the database.
If you want the services you publish to ArcGIS Server to use the data in your database or a geodatabase in PostgreSQL, register the database with your ArcGIS Server sites. See Manage registered data stores in the ArcGIS Pro help, Register your data with ArcGIS Server using Server Manager, or Add items in the ArcGIS Enterprise portal user help for instructions.