---
title: "Self-host Directus in 2026: your content and PostgreSQL, in France"
url: https://while.sh/en/guides/self-host-directus/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-19
---

# Self-host Directus in France, with its PostgreSQL database, with your AI (2026)

A back office and an API for your content, with no server to maintain. Connected to while over MCP, your AI deploys Directus in France, with its content in a PostgreSQL database backed up every day.

> **The short version.** Over MCP, your AI deploys Directus with while, in France, with your content in a PostgreSQL database backed up every day. What matters, like deleting a database, waits for a person's approval.

## Prerequisites

- A new Directus instance, or your exported schema.
- Your AI: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Ask your AI for Directus

> You, to your AI: Connect to while with my account (while.sh/agents), then deploy Directus with its PostgreSQL database.

Your AI adds while's MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn't open, type /mcp, choose while, then Authenticate. On that page, choose "A new app", then click Authorize.

## Step 2: Open your back office

Your AI gives you your Directus address, for example `https://directus.while.cloud`, with the admin account's email address and password. Sign in, change that password, then create your collections.

## What your AI does

Directus reads its database from `DB_CONNECTION_STRING` (source 1), and while provides it in `DATABASE_URL`. So your AI writes a Dockerfile, on the official Directus image, that copies one into the other at startup:

```dockerfile titre="Dockerfile"
FROM directus/directus:11
ENV PORT=8080 HOST=0.0.0.0
CMD ["sh", "-c", "export DB_CONNECTION_STRING=\"$DATABASE_URL\"; node cli.js bootstrap && pm2-runtime start ecosystem.config.cjs"]
```

Then while.yaml:

```yaml titre="while.yaml"
apiVersion: while/v1
project: directus
services:
  - name: web
    port: 8080
    health: { path: /server/health }
databases:
  - name: main
```

At startup, `node cli.js bootstrap` creates the Directus tables and the admin account, then Directus answers on `/server/health`. Your AI sets Directus's `KEY` and `SECRET` keys and the admin password in while as secrets (source 3), and sets `ADMIN_EMAIL`, `DB_CLIENT: pg` and `TELEMETRY: false` in plain text.


<figure class="illus"><img src="/illustrations/guide-heberger-1200.webp" srcset="/illustrations/guide-heberger-768.webp 768w, /illustrations/guide-heberger-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="Self-host Directus in France with no server to manage: the open-source tool and its PostgreSQL database backed up every day, served over HTTPS on while, put in production by your AI" /><figcaption>The open-source tool and its PostgreSQL database, backed up every day, in France, with no server to look after.</figcaption></figure>

## Move to your own domain

> You, to your AI: Put Directus on cms.acme.com.

Your AI declares the domain, you add the DNS records it gives you, and the HTTPS certificate follows.

## Upgrade to the latest version of Directus

> You, to your AI: Upgrade Directus to the latest version.

Your AI deploys the latest Directus image. If the new version disappoints, it rolls back to the previous one.

## Put Directus back the way it was yesterday

> You, to your AI: Restore Directus's database to yesterday at 6 pm.

Your AI prepares the restore, and you approve it: a safety backup is taken first, then the database goes back to the requested moment.

## Read your content from your AI

> You, to your AI: How many articles were published this month?

Your AI reads the Directus database in SQL over MCP, with your permissions, and it can't write to it.

## Next steps

- [Deploy Strapi and its PostgreSQL database](/en/guides/deploy-strapi/)
- [Restore your database to a precise moment](/en/guides/restore-postgresql/)

## Sources

1. [Directus, database configuration](https://directus.com/docs/configuration/database), 2026-11-02
2. [Directus, file storage](https://directus.com/docs/configuration/files), 2026-11-02
3. [Directus, security (SECRET)](https://directus.com/docs/configuration/security-limits), 2026-11-02

## Questions

### Is my content backed up?

Yes: it lives in the PostgreSQL database, which is backed up every day and can go back to a precise moment.

### Where do my images and files go?

Directus keeps them on its disk (source 2), which starts from scratch on every deployment: keep your media elsewhere, or import them again after an update.

### Can my site read the Directus API?

Yes, Directus stays public, and its own sign-in protects the back office.

### Where is my Directus hosted?

In France, by Nextmap, a French company.

### Does my AI see my credentials?

No. You paste them into while, the app uses them, and your AI never sees them. Every call is logged.
