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.
By Simon Vasconcelos Lee
Published on 3 December 202614-minute read
@license Enterprise, SSO among them, fall under a commercial licence.server, worker, db and redis.ENCRYPTION_KEY separately, somewhere safe: losing it means losing access to every secret stored in the database.127.0.0.1 behind an HTTPS reverse proxy, with an exact SERVER_URL, and open only the paths you need to the internet..env, then update by changing TAG: migrations run at startup.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.
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 repository | Licence | What that means |
|---|---|---|
| The rest of the project | AGPLv3, 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 Enterprise | Commercial licence from Twenty.com, PBC | In 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 folder | MIT | You 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.
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.
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.
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.
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.
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:
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:
services:
server:
ports:
- "127.0.0.1:3000:3000"
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.
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:
docker compose down
docker compose up -d
Caddy obtains and renews the certificate on its own, and sets the headers Twenty needs by itself:
crm.example.com {
reverse_proxy 127.0.0.1:3000
}
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.
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:
certbot --nginx -d crm.example.com
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:
| Zone | Paths | Who can reach it |
|---|---|---|
| Private | Everything else: the app, /graphql, /rest, /metadata, files | Your team only |
| Public | /webhooks, /s, /emailing | Anyone: these paths are called by services that cannot join your network |
| Cloud AI connectors | /mcp, /oauth, /.well-known | The 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:
| Setup | How the team gets in | Inbound ports | Public webhooks and cloud AI connectors |
|---|---|---|---|
| A private network, such as Tailscale | An app on each device | None | No |
| An outbound tunnel with access control | Login through your identity provider | None | Yes |
| Your reverse proxy and an IP allowlist | From the office network or a VPN | 443 | Yes |
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.
/graphql or /rest: the application itself runs on those paths./mcp, /oauth and /.well-known open to that vendor’s IP ranges.SERVER_URL; with a private address, chat and agents work with text only.127.0.0.1.TAG names a specific version.The project’s file starts four services:
| Service | Role | Its data |
|---|---|---|
server | The application and the API, port 3000; it also runs the migrations | The server-local-data volume, uploaded files |
worker | Background jobs, including sending email | The same volume |
db | PostgreSQL 16, database named default | The db-data volume |
redis | Cache and queues | No 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:
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.
PG_DATABASE_URL, SERVER_URL and ENCRYPTION_KEY can only be set in .env.IS_MULTIWORKSPACE_ENABLED=true opens the multi-workspace mode: each one gets its own subdomain, with a wildcard DNS record.Logic function execution is disabled. LOGIC_FUNCTION_TYPE=LOCAL turns them on with no sandbox, on the server itself: the documentation limits it to development and trusted environments.Twenty handles two separate things: the email the instance sends, such as invitations, and your team’s mailboxes, which it syncs.
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:
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:
docker compose ps
docker compose logs worker
worker container.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:
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:
0 2 * * * docker exec twenty-db-1 pg_dump -U postgres --clean --if-exists default > /backups/twenty_$(date +\%Y\%m\%d).sql
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.
The documentation asks for a database backup before every update. Then comes the procedure for Docker Compose:
docker compose down. The volumes stay in place.TAG in the .env file.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:
docker exec -it twenty-server-1 yarn command:prod upgrade:status
docker exec -it twenty-server-1 yarn command:prod upgrade:status --failed-only
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.
| Topic | Our teams | You |
|---|---|---|
| The server | System and security updates, server interventions included | The time that suits your business |
| Monitoring | Server watched 24/7, with intervention without waiting for your call | The choice of paths open to the internet, and your team’s access |
| Twenty | Proactive monitoring: errors, slowdowns and disk space spotted, fix recommended | Its installation, updates and settings, which you apply, yourself or through your AI assistant |
| Backups | Every night, encrypted and kept off the machine; restores included | Your database exports, safekeeping ENCRYPTION_KEY, and the restore request when you need one |
| Migration | Your current server migrated, free of charge | The 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.
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 complimentary.
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.
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.
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.
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.
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.
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.
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.
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.
Simafri
Let's talk about your website
Tell us about your project in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.