---
title: Connect ABS to MongoDB
description: The MongoDB default port for connection with ABS is 27017. Run the check_ports_abs.sh script on the ABS machine to determine whether the default port is available. Input the MongoDB host IP address and default port as arguments. For example:
component: pingintelligence
version: 5.1
page_id: pingintelligence:pingintelligence_production_deployment:pingintelligence_connect_abs_to_mongodb
canonical_url: https://docs.pingidentity.com/pingintelligence/5.1/pingintelligence_production_deployment/pingintelligence_connect_abs_to_mongodb.html
revdate: March 29, 2024
section_ids:
  check-and-open-mongodb-default-port: Check and open MongoDB default port
  configure-abs-to-connect-to-mongodb: Configure ABS to connect to MongoDB
  verify-mongodb-ssl-certificates: Verify MongoDB SSL certificates
---

# Connect ABS to MongoDB

## **Check and open MongoDB default port**

The MongoDB default port for connection with ABS is 27017. Run the `check_ports_abs.sh` script on the ABS machine to determine whether the default port is available. Input the MongoDB host IP address and default port as arguments. For example:

```
/opt/pingidentity/abs/util ./check_ports_abs.sh {MongoDB IPv4:[port]}
```

Run the script for MongoDB master and slave. If the default ports are not accessible, open the port from the MongoDB machine.

## **Configure ABS to connect to MongoDB**

ABS access key and secret key are used for MongoDB and REST API authentication. Edit `abs_init.js` in `/opt/pingidentity/mongo` directory to set the key values. Here is a sample `abs_init.js` file:

|   |                                                                                     |
| - | ----------------------------------------------------------------------------------- |
|   | ":" (colon) is a restricted character and not allowed in access key and secret key. |

```
db.auth_info.insert({
"access_key" : "abs_ak",
"secret_key" : "abs_sk"
});
```

|   |                                                                                                                                                                                                                                                              |
| - | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|   | Do not edit the `abs_init.js` file, for any subsequent changes to ABS access key and secret key. It is recommended to use `update_keys` CLI command to change the keys. For more information, see [ABS CLI](../abs_ai_engine/pingintelligence_abs_cli.html). |

Copy the `abs_init.js` file from ABS

```
/opt/pingidentity/abs/mongo
```

folder to the MongoDB system `/opt/pingidentity/mongo` folder.

At the MongoDB command prompt, update the MongoDB settings with the latest `abs_init.js` file.

```
# mongo admin -u absuser -p abs123 < /opt/pingidentity/abs/mongo/abs_init.js
MongoDB Shell version 4.2.0
connecting to: admin
switched to db abs_metadata
WriteResult({ "nInserted" : 1})
bye
```

## Verify MongoDB SSL certificates

You can configure ABS to verify the validity of MongoDB server certificate, when ABS connects with MongoDB. This is an optional check which can be enabled by setting`mongo_certificate` parameter in `/<pi_install_path>/pingidentity/abs/config/abs.properties` file. For more information, see [Verify MongoDB SSL certificates](../abs_ai_engine/pingintelligence_verify_mongodb_ssl_certificates.html).
