Directus: Connecting Directus to a PostgreSQL database

This documentation is part of the External databases guide. View the full guide here: How to connect Directus to a MySQL, MariaDB, or PostgreSQL database.

👋 Welcome to the Stackhero documentation!

Stackhero offers a Directus cloud service that is ready for production use in just 2 minutes:

  • Unlimited collections, items, users, roles, API requests, and data transfers
  • Custom domain name with built-in HTTPS for secure access (for example, https://cms.your-company.com)
  • Dedicated email server for unlimited transactional and notification emails
  • Integrated Redis cache for high performance
  • Consistent performance and strong security with private, dedicated infrastructure
  • One-click updates let you keep your system current with minimal effort

Focus on your project, not your setup: you can explore Stackhero's Directus cloud solution in just 5 minutes.

  1. Start by creating a user for Directus on PostgreSQL. Open PgAdmin, expand servers > postgresql, right-click on Login/Group Roles, and select Create > Login/Group Role....

  2. In the Name field, enter directus.

  3. Switch to the Definition tab and set a strong, secure password.

  4. Next, go to the Privileges tab, check Can login, and save the new user.

    Directus user creation on a PostgreSQL databaseDirectus user creation on a PostgreSQL database

  5. Now create a database for Directus. Right-click on Databases and choose Create > Database.

  6. Enter directus in the Database field, select directus as the owner, and save your changes.

    Directus database creation on PostgreSQLDirectus database creation on PostgreSQL

  7. Finally, navigate to your Stackhero dashboard, select your Directus service, and click Configure.

  8. Under Database, select PostgreSQL and fill in the additional fields as shown below.

    Configuration of PostgreSQL for DirectusConfiguration of PostgreSQL for Directus