|
| 1 | +--- |
| 2 | +title: External PostgreSQL |
| 3 | +description: Configure OpenHands Enterprise to use your own PostgreSQL database |
| 4 | +icon: database |
| 5 | +--- |
| 6 | + |
| 7 | +OpenHands Enterprise can connect to an external PostgreSQL instance instead of using |
| 8 | +the bundled database. This is useful when you have existing database infrastructure, |
| 9 | +need specific backup/recovery procedures, or require high availability configurations. |
| 10 | + |
| 11 | +## PostgreSQL Version |
| 12 | + |
| 13 | +OpenHands Enterprise requires **PostgreSQL 16.4.0 or above**. PostgreSQL 17 is also supported. |
| 14 | + |
| 15 | +## Required Databases |
| 16 | + |
| 17 | +OpenHands Enterprise uses the following databases: |
| 18 | + |
| 19 | +| Database | Purpose | |
| 20 | +|----------|---------| |
| 21 | +| `openhands` | Core application data | |
| 22 | +| `bitnami_keycloak` | Identity and access management | |
| 23 | +| `litellm` | LLM proxy configuration and usage tracking | |
| 24 | +| `runtime_api_db` | Runtime/sandbox management | |
| 25 | +| `automations` | Scheduled tasks and automation workflows | |
| 26 | + |
| 27 | +## Database User Requirements |
| 28 | + |
| 29 | +The PostgreSQL user provided to OpenHands Enterprise needs specific privileges depending |
| 30 | +on your preferred setup approach. |
| 31 | + |
| 32 | +### Option 1: Automatic Database Creation (Recommended) |
| 33 | + |
| 34 | +If you provide a database user with the `CREATEDB` privilege, OpenHands Enterprise will |
| 35 | +automatically create all required databases during installation. |
| 36 | + |
| 37 | +```sql |
| 38 | +-- Create user with CREATEDB privilege |
| 39 | +CREATE USER openhands_user WITH PASSWORD 'your-secure-password' CREATEDB; |
| 40 | +``` |
| 41 | + |
| 42 | +When the user creates its own databases, it will automatically have all necessary privileges |
| 43 | +on them including the ability to manage the `public` schema. |
| 44 | + |
| 45 | +### Option 2: Manual Database Creation |
| 46 | + |
| 47 | +If your security policies prevent granting `CREATEDB`, you must manually create all |
| 48 | +databases before installation: |
| 49 | + |
| 50 | +```sql |
| 51 | +-- Create the databases |
| 52 | +CREATE DATABASE openhands; |
| 53 | +CREATE DATABASE bitnami_keycloak; |
| 54 | +CREATE DATABASE litellm; |
| 55 | +CREATE DATABASE runtime_api_db; |
| 56 | +CREATE DATABASE automations; |
| 57 | + |
| 58 | +-- Create user without CREATEDB |
| 59 | +CREATE USER openhands_user WITH PASSWORD 'your-secure-password'; |
| 60 | + |
| 61 | +-- Grant privileges on each database |
| 62 | +GRANT ALL PRIVILEGES ON DATABASE openhands TO openhands_user; |
| 63 | +GRANT ALL PRIVILEGES ON DATABASE bitnami_keycloak TO openhands_user; |
| 64 | +GRANT ALL PRIVILEGES ON DATABASE litellm TO openhands_user; |
| 65 | +GRANT ALL PRIVILEGES ON DATABASE runtime_api_db TO openhands_user; |
| 66 | +GRANT ALL PRIVILEGES ON DATABASE automations TO openhands_user; |
| 67 | + |
| 68 | +-- Connect to each database and grant schema privileges |
| 69 | +\c openhands |
| 70 | +GRANT USAGE, CREATE ON SCHEMA public TO openhands_user; |
| 71 | + |
| 72 | +\c bitnami_keycloak |
| 73 | +GRANT USAGE, CREATE ON SCHEMA public TO openhands_user; |
| 74 | + |
| 75 | +\c litellm |
| 76 | +GRANT USAGE, CREATE ON SCHEMA public TO openhands_user; |
| 77 | + |
| 78 | +\c runtime_api_db |
| 79 | +GRANT USAGE, CREATE ON SCHEMA public TO openhands_user; |
| 80 | + |
| 81 | +\c automations |
| 82 | +GRANT USAGE, CREATE ON SCHEMA public TO openhands_user; |
| 83 | +``` |
| 84 | + |
| 85 | +## Network Requirements |
| 86 | + |
| 87 | +Ensure your PostgreSQL instance is accessible from: |
| 88 | + |
| 89 | +- The OpenHands application pods/services |
| 90 | +- The Keycloak service |
| 91 | +- The LiteLLM proxy service |
| 92 | +- The Runtime API service |
| 93 | + |
| 94 | +If using network policies or firewalls, allow connections on the PostgreSQL port (default: 5432) |
| 95 | +from the OpenHands deployment. |
| 96 | + |
| 97 | +## Configuration |
| 98 | + |
| 99 | +When configuring OpenHands Enterprise, provide your external PostgreSQL connection details |
| 100 | +in the Admin Console or Helm values: |
| 101 | + |
| 102 | +- **Host**: Your PostgreSQL server hostname or IP |
| 103 | +- **Port**: PostgreSQL port (default: 5432) |
| 104 | +- **Username**: The database user created above |
| 105 | +- **Password**: The user's password |
| 106 | + |
| 107 | +<Note> |
| 108 | + For production deployments, we recommend enabling SSL/TLS for database connections. |
| 109 | +</Note> |
0 commit comments