Self-host Twenty CRM on a managed VPS: your CRM on your own server

To self-host Twenty CRM on a managed VPS is to keep your clients, your deals and your conversations on a machine of your own, which our teams keep up to date and watch day and night. Twenty is an open source CRM, mostly under the AGPLv3 licence. This guide follows its official documentation: the licence, installing with Docker Compose, HTTPS, private access, email, backups and updates.

Simon Vasconcelos Lee By Published on 3 December 202614 minute read

All guides CRM, ERP and finance

In short

  1. Twenty is mostly under the AGPLv3, and self-hosting its open source core is free; files marked @license Enterprise, SSO among them, fall under a commercial licence.
  2. Install it with Docker Compose on a server with at least 2 GB of RAM: four services, server, worker, db and redis.
  3. Keep ENCRYPTION_KEY separately, somewhere safe: losing it means losing access to every secret stored in the database.
  4. Publish port 3000 on 127.0.0.1 behind an HTTPS reverse proxy, with an exact SERVER_URL, and open only the paths you need to the internet.
  5. Back up the database, the uploaded files and the .env, then update by changing TAG: migrations run at startup.

What Twenty does

Twenty is a CRM your team shapes around its business, then evolves along with it. You run it from a web interface, and its objects, views and automations can also be written and versioned as code.

What the Twenty licence allows

The project’s LICENSE file says it in one sentence: Twenty is "mostly" under the GNU AGPLv3, with two qualifications. Files under the first one carry the comment /* @license Enterprise */ at the top. Here is how the repository divides up:

Part of the repositoryLicenceWhat that means
The rest of the projectAGPLv3, with an additional permission called the "Twenty Application Exception"You use, host and modify it freely, on the terms of the AGPLv3
Files marked @license EnterpriseCommercial licence from Twenty.com, PBCIn production, they require a valid Twenty Enterprise Edition subscription; development and testing stay open without one
The twenty command-line tool and its SDKs, twenty-ui, and the applications in the twenty-apps folderMITYou keep the copyright notice and the licence text

Twenty’s website sums up everyday use: self-hosting the open source core is free. The code marks as @license Enterprise, for example, SSO, row-level permissions and viewing event logs. The documentation reserves SSO for the Organization plan, "cloud and self-hosted workspaces", and the Enterprise licence key goes in the ENTERPRISE_KEY variable.

If you modify Twenty

The name and logo remain trademarks of Twenty.com, PBC, which the licences do not cover. Its trademark policy allows you to host Twenty and say so. A company, product or domain name containing "Twenty", or an offering presented as official, requires its written permission.

Installing with Docker Compose

The documentation asks for at least 2 GB of RAM: with less, processes can crash for lack of memory. It also asks for up-to-date Docker and Docker Compose, and gives no figures for processor or disk. On a Managed VPS, tell us about your team and your data volume, and we recommend the right size.

With the official script

Terminal
bash <(curl -sL https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-docker/scripts/install.sh)

The script checks Docker, asks you for a folder (twenty by default), downloads the docker-compose.yml and .env of the latest release into it, sets TAG to that release, then generates ENCRYPTION_KEY and PG_DATABASE_PASSWORD. When it offers to start, answer n: that gives you time to set the address and the port, as shown below. For a specific version, put VERSION= and a full tag in front of the command, such as v2.56.1, released on November 5, 2026.

By hand

Terminal
curl -o .env https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/.env.example
curl -o docker-compose.yml https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/docker-compose.yml
openssl rand -base64 32
openssl rand -hex 32

The first generated value goes in ENCRYPTION_KEY, the second in PG_DATABASE_PASSWORD. Both lines are commented out in the example file: remove the #. The password goes as is into the PostgreSQL connection URL, and characters such as @, /, # or % would break it: the hexadecimal form avoids them. Also replace TAG=latest with a specific version, which the project advises so that you update when you decide to.

Settings to make before the first launch

The script has already filled in TAG and both secrets: SERVER_URL remains, the public address of your CRM. By hand, the file needs these four lines:

.env
TAG=v2.56.1
SERVER_URL=https://crm.example.com
ENCRYPTION_KEY=output_of_openssl_rand_base64_32
PG_DATABASE_PASSWORD=output_of_openssl_rand_hex_32

The project’s file publishes port 3000 on all of the server’s addresses. Docker writes its own firewall rules, and a port it publishes skips ufw. The security documentation therefore asks you to limit it to the local address, behind a reverse proxy. In docker-compose.yml, change this line of the server service:

docker-compose.yml
services:
  server:
    ports:
      - "127.0.0.1:3000:3000"
Terminal, in the docker-compose.yml folder
docker compose up -d
curl http://localhost:3000

The first start can take a few minutes while the database initializes. Then create your account right away: in the default mode, the first user becomes the instance administrator, and signups close once the first workspace exists.

The documentation cautions you to change only the settings it mentions. Every environment variable must also be declared in docker-compose.yml, at the level of server, worker or both, or it has no effect.

HTTPS, SERVER_URL and the reverse proxy

The project strongly recommends a reverse proxy with SSL termination. HTTPS also matters to the application itself: without it, some browser features, such as copy buttons, may not work on a real domain.

First create the A and AAAA DNS records for your domain, pointing to your server: visitors arrive on ports 80 and 443. SERVER_URL must then match exactly the address your users see in their browser: the server uses it for the links it generates, those in emails and OAuth callbacks, and to detect HTTPS for secure cookies. After a change:

Terminal
docker compose down
docker compose up -d

With Caddy

Caddy obtains and renews the certificate on its own, and sets the headers Twenty needs by itself:

Caddyfile
crm.example.com {
    reverse_proxy 127.0.0.1:3000
}

With Nginx and Certbot

Twenty builds its OAuth and MCP addresses from the Host and X-Forwarded-Proto headers: without them, it advertises http://127.0.0.1:3000. The settings below follow the security documentation. proxy_buffering off also serves streamed responses: without it, an AI chat reply may only appear when the page reloads.

Nginx block
server {
    listen 80;
    server_name crm.example.com;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}

Certbot then installs the Let’s Encrypt certificate, adds listening on port 443 and schedules the renewal:

Terminal
certbot --nginx -d crm.example.com

Keeping Twenty off the public internet

Your CRM holds your clients, your deals, your emails and your calendar. Twenty’s documentation points out that a security fix also tells attackers where to look, and that every instance still behind becomes a target. Updating quickly remains the real fix; in the meantime, the best protection comes down to one idea: make sure nobody on the internet can reach your instance. The documentation therefore splits the instance into three zones:

ZonePathsWho can reach it
PrivateEverything else: the app, /graphql, /rest, /metadata, filesYour team only
Public/webhooks, /s, /emailingAnyone: these paths are called by services that cannot join your network
Cloud AI connectors/mcp, /oauth, /.well-knownThe IP ranges of the vendors concerned; login stays limited to your team

Open the public and AI zones only if you use the features behind them. The documentation details three setups:

SetupHow the team gets inInbound portsPublic webhooks and cloud AI connectors
A private network, such as TailscaleAn app on each deviceNoneNo
An outbound tunnel with access controlLogin through your identity providerNoneYes
Your reverse proxy and an IP allowlistFrom the office network or a VPN443Yes

For an IP allowlist, first read in your proxy’s logs the address it sees for your visitors: that is the address the filter applies to.

What this changes

The project’s checklist

Your data: PostgreSQL, Redis, files and the encryption key

The project’s file starts four services:

ServiceRoleIts data
serverThe application and the API, port 3000; it also runs the migrationsThe server-local-data volume, uploaded files
workerBackground jobs, including sending emailThe same volume
dbPostgreSQL 16, database named defaultThe db-data volume
redisCache and queuesNo volume declared

Keep ENCRYPTION_KEY separately. It encrypts OAuth tokens, application variables, signing-key private keys, sensitive settings and two-factor secrets. The documentation is clear: losing it means losing access to every secret stored in the database. Keep it in a secrets manager, off the server.

To rotate it without downtime, put the new value in ENCRYPTION_KEY and the old one in FALLBACK_ENCRYPTION_KEY, restart, then re-encrypt the existing rows. Remove the old key once a --dry-run finds none left:

Terminal
docker exec -it twenty-server-1 yarn command:prod secret-encryption:rotate

The PostgreSQL password is written into the volume at first launch. Changing it later in .env gives the error password authentication failed for user "postgres". The documentation’s solution, docker compose down --volumes, erases the whole database: it only applies to a fresh install with no data.

By default, uploaded files stay on the server, in the volume. The documentation advises S3 or a compatible service in production, especially to spread Twenty across several servers. If you set STORAGE_TYPE to S_3, fill in every required STORAGE_S3_* variable: an empty STORAGE_S3_NAME breaks every upload.

Three settings specific to Twenty

Email: what the instance sends and connected mailboxes

Twenty handles two separate things: the email the instance sends, such as invitations, and your team’s mailboxes, which it syncs.

Email from the instance

On a Simafri VPS, sending goes through an authenticated SMTP relay on port 587: the address of a mail account you already have, or Simafri Suite. In Twenty’s code, EMAIL_DRIVER defaults to logger: messages stay in the logs until you set it to smtp. Set it in "Settings", "Admin Panel", "Configuration Variables", "Email" section:

Configuration Variables
EMAIL_DRIVER=smtp
EMAIL_SMTP_HOST=smtp.example.com
EMAIL_SMTP_PORT=587
EMAIL_SMTP_USER=notifications@example.com
EMAIL_SMTP_PASSWORD=your_password
EMAIL_FROM_ADDRESS=notifications@example.com
EMAIL_FROM_NAME=Example

If nothing goes out, the documentation looks first at the worker, since most of the time it is the one not running:

Terminal
docker compose ps
docker compose logs worker

Your team’s mailboxes and calendars

Backups and updates

Three things make a complete backup: the PostgreSQL database, the volume of uploaded files and your .env file with its key. From the docker-compose.yml folder:

Terminal
docker exec twenty-db-1 pg_dump -U postgres --clean --if-exists default > twenty-$(date +%F).sql
docker run --rm --volumes-from twenty-server-1 -v "$(pwd)":/backup ubuntu tar czf /backup/twenty-files-$(date +%F).tar.gz /app/packages/twenty-server/.local-storage

The documentation’s Docker Compose page illustrates this backup with a twenty-postgres container and a twenty database. The published file names the service db and the database default, hence twenty-db-1 in the command above. PostgreSQL’s --clean --if-exists options let you restore over an existing database. Adjust -U if you changed PG_DATABASE_USER.

For an export every night, add this line with crontab -e, once the /backups folder exists. The nightly backup of a Managed VPS copies the entire server, these exports included, and the export also gives you a consistent copy of the database at its own hour:

crontab
0 2 * * * docker exec twenty-db-1 pg_dump -U postgres --clean --if-exists default > /backups/twenty_$(date +\%Y\%m\%d).sql

Restoring

Terminal, in the docker-compose.yml folder
BACKUP_DATE=2026-11-01
(
  set -e
  for f in twenty-$BACKUP_DATE.sql twenty-files-$BACKUP_DATE.tar.gz; do
    test -s "$f" || { echo "Missing or empty: $f"; exit 1; }
  done
  docker compose stop server worker
  docker exec -i twenty-db-1 psql -U postgres default < twenty-$BACKUP_DATE.sql
  docker run --rm --volumes-from twenty-server-1 -v "$(pwd)":/backup ubuntu bash -c "cd /app/packages/twenty-server/.local-storage && tar xzf /backup/twenty-files-$BACKUP_DATE.tar.gz --strip 4"
  docker compose up -d
)

Set BACKUP_DATE, on the first line, to the date in the names of the backup you restore, as listed by ls. The commands run in parentheses with set -e, which stops them at the first error. They first check that each file exists and is not empty, before anything is stopped, removed or overwritten: a wrong date stops there, with your data untouched, and a failed step stops every step after it, so the application is never started again on a partial restore.

The project advises testing your restores regularly, keeping daily, weekly and monthly copies, encrypting them and storing some off-site.

Updating

The documentation asks for a database backup before every update. Then comes the procedure for Docker Compose:

  1. Stop Twenty: docker compose down. The volumes stay in place.
  2. Change the value of TAG in the .env file.
  3. Start it again: docker compose up -d. The server runs the migrations on its own at startup.

To follow the state of the migrations, or spot a workspace that failed. If a step fails, the server stops there, and another docker compose up -d picks up from the same place:

Terminal
docker exec -it twenty-server-1 yarn command:prod upgrade:status
docker exec -it twenty-server-1 yarn command:prod upgrade:status --failed-only

Who does what on a Managed VPS

Self-hosting means running the server on top of the application. On a Managed VPS, our teams take the server in hand and proactively monitor your instance; Twenty remains your software, with its settings and its data.

TopicOur teamsYou
The serverSystem and security updates, server interventions includedThe time that suits your business
MonitoringServer watched 24/7, with intervention without waiting for your callThe choice of paths open to the internet, and your team’s access
TwentyProactive monitoring: errors, slowdowns and disk space spotted, fix recommendedIts installation, updates and settings, which you apply, yourself or through your AI assistant
BackupsEvery night, encrypted and kept off the machine; restores includedYour database exports, safekeeping ENCRYPTION_KEY, and the restore request when you need one
MigrationYour current server migrated, free of chargeThe time of the switchover

If you would rather have our teams work inside the application itself, that service is billed hourly or at a fixed price, with a quote given before the work begins.

Twenty CRM, on a server run for you

With a Simafri Managed VPS, our teams keep your Twenty instance’s server up to date, monitor it day and night and step in without waiting for your call; they also proactively monitor your instance and recommend useful fixes, which you apply, yourself or through your AI assistant. Backups are encrypted every night and kept off the machine, restores are included, and migrating your current server is free.

Explore Managed VPS

Frequently asked questions

Is self-hosted Twenty CRM free?

Twenty’s website states that self-hosting the open source core is free. The project is mostly under the AGPLv3. Files marked @license Enterprise, SSO among them, require a subscription from Twenty in production. What remains is the cost of the server that runs it.

What license does Twenty CRM use?

Mostly the AGPLv3, with an exception for applications built on its APIs. Files marked @license Enterprise are under a commercial licence, and some packages, such as the application development toolkit and twenty-ui, are under MIT. A modified version open to people outside your organization must offer them its source code.

How do I install Twenty CRM with Docker Compose?

Run the official install.sh script, or download the project’s .env file and docker-compose.yml, fill in ENCRYPTION_KEY, PG_DATABASE_PASSWORD and SERVER_URL, then run docker compose up -d. The application answers on port 3000, and the first account created becomes the administrator.

How much RAM does Twenty CRM need?

The documentation asks for at least 2 GB of RAM: with less, processes can crash for lack of memory. It gives no figures for processor or disk. Tell us about your team and your data volume, and we recommend the right VPS size.

How do I back up Twenty CRM?

Export the database with pg_dump from the twenty-db-1 container, database default, archive the server-local-data volume, and keep your .env file separately. Without ENCRYPTION_KEY, you lose access to every secret stored in the database: OAuth tokens, application variables, two-factor secrets.

How do I update Twenty CRM?

Back up the database, run docker compose down, change TAG in the .env file, then run docker compose up -d. The server runs the migrations on its own at startup. Since v1.23, you go straight to the latest version, and the upgrade:status command shows where the migrations stand.

Should Twenty CRM be exposed to the internet?

The documentation advises keeping the application private and opening only the paths you need: /webhooks, /s and /emailing if you use the features concerned, /mcp, /oauth and /.well-known for cloud AI connectors. Do not make /graphql or /rest public.

Does a Managed VPS cover Twenty CRM?

A Managed VPS covers the server: system, security, monitoring and backups. Our teams also proactively monitor your instance and recommend useful fixes, which you apply. Work inside the application is billed hourly or at a fixed price.

Contact us