AFFiNE is an open-source workspace for notes, documents, and whiteboards. You can write text with tables, task lists, and Kanban views, much like in Notion, then switch to whiteboard mode (Edgeless) with one click to arrange, draw, and connect the same content freely on a canvas, just as in Miro. You can work in your browser or in the AFFiNE app for Windows, macOS, and Linux. When you run the AFFiNE server yourself, your workspaces are stored on your VPS and synced from there across your devices and team.
This guide shows you two ways to get started: the easy way, as a One-Click App, which makes AFFiNE available over HTTPS with PostgreSQL and Redis, and a manual installation with Docker Compose using the official template. Afterward, you’ll create a workspace on your server, invite members, connect the desktop app, and learn about the limitations of the self-hosted server.
Running your own AFFiNE server is worthwhile if you want notes, planning, and sketches in one place under your own control. It’s a good fit if:
- you want your content stored on your own server, for example for privacy reasons or because you don’t want to store your team’s knowledge with a cloud provider.
- you want to combine documents and whiteboards, for example by turning a project description into a process diagram in whiteboard mode.
- a small team needs to work together: the free self-hosting version allows up to 10 members per workspace.
- you work across multiple devices and want to sync your browser and desktop app through your server.
A server of your own is less suitable if you only use AFFiNE by yourself on one computer. Without a server, AFFiNE creates a local workspace stored in your browser or app. For more than 10 people in a workspace, you need a paid AFFiNE license (see “Limitations” for more details).
Both are open-source alternatives to Notion that you can self-host. We have a separate guide for setting up an AppFlowy server. Here are the main differences:
| AFFiNE | AppFlowy | |
|---|---|---|
| Focus | Documents and a whiteboard on one canvas | Documents, databases, Kanban, calendars |
| Free self-hosting tier | Up to 10 members per workspace | One full-featured user seat |
| One-Click App services | 4 containers (AFFiNE, Migration, PostgreSQL, Redis) | Around 10 containers |
If you mainly manage structured databases, tasks, and calendars by yourself, AppFlowy is the better choice. If you write and sketch with a small team, AFFiNE is a better fit.
The fastest way to get AFFiNE is through your VPS’s One-Click Apps. The app installs the AFFiNE server with its own PostgreSQL database (with the pgvector extension), Redis, and a migration service that prepares the database on every startup. With a domain, AFFiNE is immediately available over HTTPS, and the public address is configured automatically. You don’t need a reverse proxy, certificate, or firewall rules.
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See VPS: One-Click Apps for instructions.
- At least 2 vCPU cores, 1.5 GB of free RAM, and 5 GB of free storage; 4 vCPU cores, 4 GB of RAM, and 20 GB of storage are recommended. In our test, all services together used around 370 MB of RAM immediately after startup, and the images used about 1.8 GB of storage. Requirements increase with more documents, images, and users.
- Open your VPS in the ZapX dashboard and switch to the One-Click Apps tab.
- Search for “AFFiNE” in the App catalog and click Install app for AFFiNE.
- Use a custom subdomain or zap.cloud is already selected with a random name. Leave it enabled or enter a custom name, such as
notes. Without a domain, AFFiNE is only available over HTTP; you should use HTTPS for logins and the desktop app. - You don’t need to fill anything in under App configuration.
POSTGRES_DBis the name of the internal database (defaultaffine), while the database username and password (SERVICE_USER_POSTGRES,SERVICE_PASSWORD_POSTGRES) are generated automatically. You can leave theMAILER_*andCOPILOT_*fields empty. It’s easier to set up email delivery later in the AFFiNE admin area. LeaveAFFINE_REVISIONat its default value; otherwise, the migration service and server will run different versions. - Click Queue installation.
On the first startup, the migration service creates the database tables and then exits. This takes about a minute. Once the app card shows Online, you can open AFFiNE.
The One-Click App only generates credentials for the internal database. No AFFiNE account exists yet after installation. The first time you open AFFiNE, it redirects to the setup page at /admin/setup. Whoever completes this page becomes the server administrator.
Until the first account exists, anyone who visits your app’s address can create the administrator account and take over the server. New addresses are often picked up by automated scanners within minutes. So open AFFiNE as soon as the app is Online and complete the setup.
- Open AFFiNE using the Access link on the app card. You’ll see the “Welcome to AFFiNE” page. Click Continue.
- Under Create Administrator Account, enter your Name, Email, and a Password between 8 and 32 characters.
- Click Continue. AFFiNE creates your account and opens the admin area at
/admin.
You also use this account to sign in as a regular AFFiNE user. You can access the admin area, with Accounts, Settings, and About, at any time at https://your-address/admin. Open the workspace interface at the main address.
By default, AFFiNE allows new registrations (Admin > Settings > Auth > “Whether allow new registrations.”). However, AFFiNE creates new accounts using a sign-in link sent by email. This means nobody can register themselves until you configure a mail server. In our test, the server rejected attempts with “Email service is not configured.”
If you set up a mail server so invitations can be sent by email, anyone can then create an account using an email address. If you only want invited people on your server, turn off “Whether allow new registrations.” under Auth and click Save.
Enter the mail server details under Admin > Settings > Notification: host, port, username, password, and sender (for example, AFFiNE <noreply@example.com>). Use Send Test Email to check the settings.
Outgoing ports 25 and 465 are blocked on VPSs. For AFFiNE, use a mail server that offers port 587 (STARTTLS), such as your email provider’s mailbox.
The One-Click App uses a fixed version of AFFiNE. To check whether a new version is available in the catalog, open the app card’s gear menu and select App update > Check for updates. If one is available, install it with Apply update. On the next startup, the migration service automatically updates the database. AFFiNE doesn’t describe a way to roll back to an older version, so you’ll need a backup made before the update.
That’s why you should back up your VPS in the Backups tab before every update. The app stores its data in Docker volumes: affine-postgres-data (database with all documents and accounts), affine-storage (uploaded images and files), and affine-config (server key file). All three belong in the same backup.
If you want to run AFFiNE without One-Click Apps, install it with Docker Compose using AFFiNE’s official template.
You need a Linux server with root access over SSH and Docker with the Compose plugin. See Install Docker for instructions. To access AFFiNE over HTTPS, you’ll also need a domain or subdomain that points to your server’s IP address.
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 2 vCPU | 4 vCPU |
| RAM | 1.5 GB | 4 GB |
| Storage | 5 GB | 20 GB |
AFFiNE listens on port 3010. Don’t expose this port externally: the Compose file below binds it only to 127.0.0.1. You’ll access AFFiNE through the reverse proxy on port 443. With ufw, this looks like:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
If you’ve enabled your VPS’s network firewall in the ZapX dashboard, allow only ports 22, 80, and 443 there as well. For more information, see VPS: Firewall.
Create a folder and download the Compose file and example configuration for the version you want to install. Here we’re using version 0.27.4, which is also used by the One-Click App:
mkdir -p /opt/affine/config && cd /opt/affine
curl -L -o docker-compose.yml https://github.com/toeverything/AFFiNE/releases/download/v0.27.4/docker-compose.yml
curl -L -o config/config.json https://github.com/toeverything/AFFiNE/releases/download/v0.27.4/config.json.example
Open config/config.json and enter the future HTTPS address for externalUrl:
{
"$schema": "https://github.com/toeverything/affine/releases/latest/download/config.schema.json",
"server": {
"name": "AFFiNE Self-hosted",
"externalUrl": "https://affine.example.com"
}
}
The address must be exactly right: AFFiNE uses it to build links in invitations and sign-in links. name is the server name shown in the desktop app.
Make two changes in docker-compose.yml: for affine and affine_migration, replace the image ghcr.io/toeverything/affine:stable with ghcr.io/toeverything/affine:0.27.4 so a restart doesn’t unexpectedly move to a newer version. Also bind the port locally only:
ports:
- '127.0.0.1:3010:3010'
The most important parts of the template:
affine_migrationruns theself-host-predeploy.jsscript, creates the tables, and exits.affinestarts only after this service has completed successfully../data/storagecontains uploaded files,./configcontains the configuration and server key file, and./data/postgrescontains the database.- PostgreSQL runs with the
pgvector/pgvector:pg16image andPOSTGRES_HOST_AUTH_METHOD: trust. This is only acceptable because the database doesn’t expose a port externally and is accessible only on the internal Docker network. Therefore, never add aportsentry topostgres.
Start AFFiNE:
docker compose up -d
docker compose ps
affine_migration_job must exit with code 0, while affine_server, affine_postgres, and affine_redis continue running. If you run into problems, check docker compose logs --tail=200 affine affine_migration.
Until the reverse proxy is set up, access AFFiNE through an SSH tunnel. Run this command on your own computer:
ssh -L 3010:127.0.0.1:3010 root@SERVER_IP
Then open http://localhost:3010 in your browser and create the administrator account as described above. This prevents anyone else from completing the setup. Afterward, set up access over HTTPS.
To access AFFiNE externally, put nginx in front of it. For the basics, see VPS: Reverse Proxy with nginx; create the certificate as described in VPS: Create an SSL Certificate. AFFiNE syncs documents over WebSockets, so you need to add the Upgrade headers:
server {
listen 80;
server_name affine.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name affine.example.com;
ssl_certificate /etc/letsencrypt/live/affine.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/affine.example.com/privkey.pem;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:3010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
}
}
client_max_body_size limits the size of individual uploads; adjust it to suit your files. Check the configuration with nginx -t and reload nginx with systemctl reload nginx.
If you’ve entered a mail server, registration is open to everyone. Turn it off under Admin > Settings > Auth if only invited people should be able to create accounts.
For a consistent backup, briefly stop AFFiNE and back up the entire folder:
cd /opt/affine
docker compose stop
tar czf /root/affine-backup-$(date +%F).tar.gz docker-compose.yml config data
docker compose start
If you don’t want to stop AFFiNE, back up the database with pg_dump and also back up the config and data/storage folders:
docker compose exec -T postgres pg_dump -U affine affine > /root/affine-db-$(date +%F).sql
Don’t keep backups only on the same server; copy them regularly to another computer.
Before each update, read the release notes for the target version and create a backup. Download the Compose file for the new version into a separate file and compare it with yours:
cd /opt/affine
curl -L -o docker-compose.yml.new https://github.com/toeverything/AFFiNE/releases/download/vX.Y.Z/docker-compose.yml
diff -u docker-compose.yml docker-compose.yml.new
Carry your changes (fixed version, port bound only to 127.0.0.1, data paths) over to the new file, replace the old one, and restart:
mv docker-compose.yml.new docker-compose.yml
docker compose pull
docker compose up -d
The migration service updates the database on startup. Afterward, check sign-in, workspaces, editing, and uploads before deleting old backups. AFFiNE notes that a Compose file with changed paths can start PostgreSQL with an empty data directory. Therefore, never run docker compose down -v or delete old data directories before you’ve checked the update.
After setup, you’ll work in the main AFFiNE interface. A few things work differently from Notion.
When you first open AFFiNE, you’ll see a Demo Workspace with sample pages. This workspace exists only in your browser; the message “Your workspace is saved in this browser” appears at the top. Its content isn’t on your server and will be lost if the browser’s data is cleared.
To create a workspace on your server:
- Click the workspace name in the top-left corner.
- Select Create workspace.
- Enter a name under Workspace name. Under Workspace type, select AFFiNE Self-hosted, which is your server.
- Click Create.
To move an existing local workspace to your server, select Enable Cloud in the same list or Enable AFFiNE Sync in the notice.
Manage members in the workspace settings: Settings > Members > Invite members. There are two options:
- Email Invite sends an invitation by email. This works only if you’ve configured a mail server.
- Invite Link creates an invitation link that’s valid for 7 days. Click Generate and share the link.
AFFiNE doesn’t allow new accounts to invite members or create share links until they’re a day old. This also applies to your newly created administrator account. Clicking Generate will show “Failed to generate invitation link.” If you don’t want to wait, go to Admin > Settings > Auth and change “Minimum account age in seconds before new accounts can invite members or create share links.” from 86400 to a lower value, such as 0, then click Save.
Without a mail server, invited users can’t register themselves. Create their accounts in the admin area instead: go to Admin > Accounts > Add User, enter a User name, Email, and Password, then confirm. The person can then sign in with their email address and password and join the workspace using your invitation link. Turning on the Admin switch in the same form also gives an account access to the admin area.
The AFFiNE app for Windows, macOS, and Linux connects to your server as follows:
- Open the workspace list in the top-left corner of the app.
- Add your server and enter its address, for example,
https://affine.example.com. - Sign in with your AFFiNE account.
The app displays the server under its name (default: “AFFiNE Self-hosted”). Change the name under Admin > Settings > Server. In your browser, simply open your app’s address.
AFFiNE’s AI features don’t use AFFiNE’s cloud when running on your own server. You’ll need your own API key from an AI provider (Bring Your Own Key). Under Admin > Settings > AI BYOK, choose whether AI features are enabled and which providers are allowed. The workspace owner then enters the key under Settings > Integrations. The AI provider bills you directly for requests.
- 10 members per workspace: Under Settings > License, the free self-hosting version shows “Basic version: 10 seats.” AFFiNE offers a paid Team plan for more seats, activated with a license file or key.
- Local workspaces aren’t backed up: Only workspaces of type AFFiNE Self-hosted are stored on your server and included in your backups.
- AI requires your own key: The AI features available in AFFiNE Cloud without your own key are only available on your server through AI BYOK.
- You can’t roll back after updates: After an update, the migration service has changed the database. You can run an older version only from a backup made before the update.
AFFiNE lets you run a shared workspace for documents and whiteboards on your own VPS. The fastest way is the One-Click App: install it, create the administrator account immediately, create a workspace of type AFFiNE Self-hosted, and invite your team with a link. If you want full control, use the manual installation with Docker Compose and nginx. In either case, remember to check the registration settings and create a backup before every update.
