---
title: PostgreSQL
description: Configure DurableStack with PostgreSQL for durable, distributed execution.
order: 53
available_in: [dotnet, nodejs]
---

# PostgreSQL

PostgreSQL is the recommended default for most production DurableStack deployments.

It supports durable state and multi-worker distributed coordination through shared tables.

## Registration

:::code-group
```csharp
using DurableStack.Hosting.DependencyInjection;

var connectionString = "Host=localhost;Port=5432;Database=durable_stack;Username=postgres;Password=postgres";

builder.Services.AddDurableStackPostgres(connectionString, options =>
{
    options.WorkerName = $"orders-api-{Environment.MachineName}-{Environment.ProcessId}";
});
```

```typescript
import { createDurableStackPostgres } from "durablestack";

const { runtime } = await createDurableStackPostgres(
  { connectionString: process.env.DATABASE_URL! },
  {
    workerName: `orders-api-${process.pid}`
  }
);
```
:::

## Operational notes

- Run migrations on startup using your runtime's migration path (for example, `IDurableStackStoreMigrator` in .NET).
- Keep retention enabled to control run-history growth.
- Validate multi-worker behavior in staging before scaling out.
