# Custom database connection with RDS Postgres

**URL:** <https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [July 18, 2025, 12:06am UTC](https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349 "2025-07-18T00:06:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anosh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anosh/32/71656_2.png) [@anosh](https://community.auth0.com/u/anosh)\
**Post date:** [July 18, 2025, 12:06am UTC](https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349/1 "2025-07-18T00:06:44Z")

</div>

I have an Auth0 SPA that I would like to link to an RDS Postgres custom database. I have set up the custom database in the Authentication\>Database section of the dashboard, but am struggling to successfully implement the necessary Database Action Scripts.

When I import and “Save And Try” the template PostgreSQL scripts provided by Auth0, I keep receiving an error stating “[SandboxUnhandledError] postgres.connect is not a function”. I have updated the script with my RDS details, but still receive this error (which seems to be a node-postgres library issue?).

Any help on this would be much appreciated, super frustrating that the template script doesn’t work

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [July 23, 2025, 7:51pm UTC](https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349/3 "2025-07-23T19:51:40Z")

</div>

Hi @anosh

Welcome to the Auth0 Community!

The error that you are facing is usually resolved by specifically indicating the version of the ‘pg’ package that is being used in your DB Script, according to the Node runtime version used in your tenant. You can get the versions to use by looking at [Can I require? - Search which node modules you can use in webtask.io](https://auth0-extensions.github.io/canirequire/#pg).

In this sense, you will need to add the ‘pg’ version under a similar format ( the following example is for Node 22) :

```auto
const postgres = require('pg@8.7.1')

```

Adding to the above, this has been mentioned in the following post as well : [Own database PostgresSQL no longer functionall - #3 by vdgandrew](https://community.auth0.com/t/own-database-postgressql-no-longer-functionall/96164/3)

Hope this helped!  
Gerald

---

<div class="post-metadata">

**Author:** ![anosh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anosh/32/71656_2.png) [@anosh](https://community.auth0.com/u/anosh)\
**Post date:** [July 31, 2025, 3:45pm UTC](https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349/4 "2025-07-31T15:45:16Z")

</div>

Thanks @gerald.czifra, I had tried require unsuccessfully earlier, but hadn’t checked my Node runtime version. Will give that a shot!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 14, 2025, 3:45pm UTC](https://community.auth0.com/t/custom-database-connection-with-rds-postgres/189349/5 "2025-08-14T15:45:35Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
