# PostgreSQL (/docs/databases-and-storage/postgresql)



[PostgreSQL](https://github.com/postgres/postgres) is a powerful, open-source relational database. Rock8Cloud supports versions 14 through 17.

Every service also ships with pgvector installed, so you can store and search embeddings in the same database. See [Vector Search](/docs/databases-and-storage/vector-search).

## Create a PostgreSQL Service [#create-a-postgresql-service]

1. Click **Add Service** in your project
2. Select **Database**
3. Choose **PostgreSQL**
4. Select a version (14, 15, 16, or 17) and storage size
5. Enter a name (e.g., `postgres-main`, `postgres-api`)
6. Click **Create**

Rock8Cloud provisions the database with secure credentials and networking handled automatically.

***

## Environment Variables [#environment-variables]

After creation, Rock8Cloud exposes these variables for your application to connect:

| Variable   | Description         | Example                                  |
| ---------- | ------------------- | ---------------------------------------- |
| `HOST`     | Database hostname   | *(auto-generated)*                       |
| `PORT`     | Database port       | `5432`                                   |
| `NAME`     | Database name       | `postgres-main`                          |
| `USER`     | Username            | `app`                                    |
| `PASSWORD` | Password            | *(auto-generated)*                       |
| `URL`      | Full connection URL | `postgresql://app:pass@host:5432/dbname` |

### Linking to Your Application [#linking-to-your-application]

1. Go to your application service → **Deployments** → **Env Vars**
2. Add the database variables using the names expected by your framework

**Common framework patterns:**

```bash
# Node.js / Prisma / Drizzle
DATABASE_URL=<URL>

# Django
DATABASE_HOST=<HOST>
DATABASE_PORT=<PORT>
DATABASE_NAME=<NAME>
DATABASE_USER=<USER>
DATABASE_PASSWORD=<PASSWORD>

# Rails
DATABASE_URL=<URL>
```

After saving, your application automatically redeploys with the new configuration.

***

## Logs and History [#logs-and-history]

A database service has three tabs of its own:

* **Logs** - live runtime logs streamed from the database pods. Click **Start Logs** to stream, scroll up to load older lines, and use copy or export to pull them out
* **History** - every deployment of this database with its status, version, storage size, and replica count. The current one is highlighted at the top
* **Resources** - replicas and the CPU / memory allocation drawn from your plan's pool, with the pool meters and a shortcut to buy more. Changes apply right away

Use History to see when a version or storage change actually landed.

***

## Features [#features]

* **Versions 14-17** - choose the version that matches your requirements
* **[Vector search built in](/docs/databases-and-storage/vector-search)** - pgvector is preinstalled for embeddings, semantic search, and agent memory
* **Persistent storage** - data survives restarts and redeployments
* **Network-isolated** - only accessible from services within the same project
* **Secure credentials** - auto-generated usernames and passwords
* **Production-grade** - managed with automated failover and monitoring

***

## Troubleshooting [#troubleshooting]

### Connection refused [#connection-refused]

* Verify the `HOST` variable is correct - use the auto-generated hostname provided by Rock8Cloud
* Ensure your application service is in the same project as the database
* Check that the database deployment completed successfully

### Authentication failed [#authentication-failed]

* Double-check `USER` and `PASSWORD` variables match what was provisioned
* If using `URL`, ensure it's the complete connection string with all components

### Database not found [#database-not-found]

* Verify the `NAME` variable matches the provisioned database name
* The database name is typically the same as the service name you chose during creation

***

## Related [#related]

* [Vector Search](/docs/databases-and-storage/vector-search) - store and query embeddings with pgvector
* [Dragonfly](/docs/databases-and-storage/dragonfly) - Redis-compatible in-memory datastore
* [S3 Object Storage](/docs/databases-and-storage/s3-storage) - S3-compatible object storage
* [Environment Variables](/docs/guides/environment-variables) - Configure secrets and settings
