On this page
- What does an AFFiNE server need?
- Where do the AFFiNE Compose files come from?
- Which values in the .env file should you change?
- How do you start AFFiNE and check it?
- How do you serve AFFiNE over HTTPS?
- How do you create the administrator and tune settings?
- How should AFFiNE send email?
- How do you back up and update the workspace?
- Questions
What does an AFFiNE server need?
Plan for 2 GB of memory as a minimum and 4 GB for a team, since the stack includes the Node.js server, PostgreSQL with the pgvector extension, and Redis. Disk use grows with pasted images and attachments, which AFFiNE keeps in a local folder.
Before installing, make sure you have:
- A host name such as
notes.example.netwith A and AAAA records pointing at the server. - Docker Engine and the Compose plugin, either from the Docker tutorial or preinstalled through the Docker image.
- A sudo user; your first SSH session covers creating one.
Swap helps on 2 GB plans during upgrades, when migrations and the new container run side by side; see adding a swap file.
Where do the AFFiNE Compose files come from?
The project attaches a ready Compose file and an example environment to every release, which is the documented self-hosting route. Download both into their own directory:
sudo mkdir -p /opt/affine && sudo chown deploy: /opt/affine
cd /opt/affine
wget -O docker-compose.yml https://github.com/toeverything/affine/releases/latest/download/docker-compose.yml
wget -O .env https://github.com/toeverything/affine/releases/latest/download/default.env.exampleOpen docker-compose.yml before you start it. You will see the main affine service, a one-shot migration job that prepares the database, plus redis and postgres services. The migration job must finish successfully before the server starts, and Compose handles that ordering for you.
Which values in the .env file should you change?
The example file uses relative folders under your home directory. Point them at fixed paths and set a real database password:
AFFINE_REVISION=stable
PORT=3010
DB_DATA_LOCATION=/opt/affine/postgres
UPLOAD_LOCATION=/opt/affine/storage
CONFIG_LOCATION=/opt/affine/config
DB_USERNAME=affine
DB_PASSWORD=a-long-random-password
DB_DATABASE=affineGenerate the password with openssl rand -hex 20. AFFINE_REVISION selects the image channel: stable follows tested releases, while other channels track newer and less proven builds. Keep the file private with chmod 600 .env.
The published port in the Compose file is the value of PORT on all interfaces. Change the mapping to 127.0.0.1:${PORT}:3010 so the app is reachable only through your reverse proxy.
How do you start AFFiNE and check it?
Bring the stack up and follow the migration job:
cd /opt/affine
docker compose up -d
docker compose ps
docker compose logs -fThe migration container exits with code 0 after it prepares the schema; the main server then reports that it is listening. A local request proves the app answers before any proxy is involved:
curl -I http://127.0.0.1:3010An HTTP 200 means the server is up. If the main container restarts repeatedly, the log almost always points to a wrong database password or an unwritable storage folder.
How do you serve AFFiNE over HTTPS?
Collaborative editing uses WebSockets, so the proxy must pass the upgrade headers. With Nginx on Ubuntu or Debian (sudo apt install nginx certbot python3-certbot-nginx), or on Rocky and Alma from EPEL, create /etc/nginx/conf.d/affine.conf:
server {
listen 80;
listen [::]:80;
server_name notes.example.net;
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-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d notes.example.netOn Rocky or Alma also allow Nginx to reach local ports with sudo setsebool -P httpd_can_network_connect 1. Caddy needs only notes.example.net { reverse_proxy 127.0.0.1:3010 } and proxies WebSockets without extra lines (Caddy HTTPS).
For the firewall, the web ports are all AFFiNE needs from outside. Run sudo ufw allow 80,443/tcp on Ubuntu or Debian; Rocky and Alma take sudo firewall-cmd --permanent --add-service=https --add-service=http and then a --reload.
How do you create the administrator and tune settings?
Visit https://notes.example.net/admin. On a new instance it asks you to create the first account, which becomes the administrator. The admin panel then holds the server settings: the public base URL, whether new users may sign up, file size limits and storage quotas.
Set the server host to notes.example.net with HTTPS enabled there as well, otherwise invitation links and shared page links point to the wrong address. Then turn off open sign-up if the workspace is private and invite colleagues by email from the workspace members screen.
The desktop and mobile apps can connect to a self-hosted server too: choose to add a server and enter the full HTTPS address.
How should AFFiNE send email?
Invitations and password resets go out through the mailer settings in the admin panel. Enter an authenticated relay host, port 587, a username and password, and a sender such as notes@example.net. Outbound port 25 is not something to count on; ask support in a ticket before you design anything around direct delivery, and use the relay for day to day mail.
Send yourself an invitation to confirm the setup. If it does not arrive, look at docker compose logs affine | grep -i mail and verify that your domain publishes SPF and DKIM records for the relay, as covered in SPF, DKIM and DMARC.
How do you back up and update the workspace?
Everything lives in the three folders named in .env. Dump the database while it runs and archive the storage and config folders:
cd /opt/affine
docker compose exec -T postgres pg_dump -U affine affine | gzip > /opt/affine-db-$(date +%F).sql.gz
sudo tar -czf /opt/affine-files-$(date +%F).tar.gz storage configCopy the archives to another machine with rsync. Updating follows the same pattern as the install: refresh the Compose file from the latest release if the notes mention changes, then pull and recreate so the migration job runs again:
docker compose pull
docker compose up -d
docker compose logs --tail=50Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about AFFiNE workspace
Does a self-hosted AFFiNE work offline?
The apps keep a local copy of each workspace and sync changes to your server when the connection returns, so short outages do not block editing.
Can I import notes from other tools?
AFFiNE imports Markdown and HTML files and offers importers for some note tools from the workspace menu. Check the import list in your version, since it grows over time.
Is the pgvector database image required?
Yes, keep the database image named in the official Compose file. Newer features store embeddings in PostgreSQL and expect the vector extension to be present.
How much traffic does editing use?
Text edits are small. Images and attachments account for most transfer, and every plan lists its monthly outgoing transfer on the prices page.
Why does the page load but collaboration never connects?
The proxy is not forwarding WebSocket upgrades. Add the Upgrade and Connection headers shown above, or use Caddy, which forwards them on its own.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM