Self-Host AFFiNE on Windows with Docker & WSL
Cloud apps give you convenience, but they come with risks. If your internet fails or a service changes terms, your data could vanish. Self-hosting AFFiNE solves this problem by letting you run a private workspace on your own machine. This guide walks you through setting up AFFiNE on Windows using Docker and WSL—no cloud dependency required.
Why Self-Host AFFiNE?
AFFiNE is a hybrid workspace for notes, tasks, and diagrams. While its cloud version is convenient, self-hosting offers three key advantages:
- Data ownership: Your notes stay local, never leaving your machine.
- Privacy: Avoid third-party access to sensitive ideas.
- DevOps skills: Learn Docker and WSL, valuable tools for modern developers.
Prerequisites
Before starting, ensure you have:
- WSL 2 installed on Windows (Ubuntu recommended).
- Docker and Docker Compose running.
- Basic Linux terminal knowledge (commands like
mkdir,cd, andwget).
Step-by-Step Setup
1. Create a Workspace Folder
Organize your files by creating a dedicated folder:
mkdir affine
2. Download AFFiNE Files
Use WSL to fetch the Docker configuration:
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.example
3. Configure the .env File
Edit the .env file to set storage paths and credentials:
DB_DATA_LOCATION=./postgres
UPLOAD_LOCATION=./storage
CONFIG_LOCATION=./config
DB_USERNAME=affine
DB_PASSWORD=your_password
4. Launch the System
Start the Docker containers in the background:
docker compose up -d
5. Access the Admin Panel
Open http://localhost:3010 in your browser and create an admin account. This is your gateway to managing the server.
6. Customize Your Server
Use the admin panel (/admin/settings) to rename your workspace or configure email settings. For advanced users, create a config.json file in the ./config folder:
{
"server": {
"name": "My Private Workspace"
}
}
7. Connect the Desktop App (Optional)
Download the AFFiNE desktop app, add your server via http://localhost:3010, and sync your workspace across devices.
8. Stop and Backup Safely
Shut down the server before backing up:
docker compose down
Copy the affine folder to an external drive for safe storage.
9. Upgrade AFFiNE Later
When updates are released, run:
wget -O docker-compose.yml https://github.com/toeverything/affine/releases/latest/download/docker-compose.yml
docker compose pull
docker compose up -d
Troubleshooting Common Errors
- Docker not running: Start Docker Desktop on Windows.
- WSL integration issue: Enable WSL in Docker Desktop settings.
- Port conflict: Change
3010:3010to4000:3010indocker-compose.yml. - Permission denied: Use
sudo rm -rf affine/to delete folders.
Conclusion
You’ve now built a self-hosted AFFiNE workspace, mastering Docker, WSL, and PostgreSQL. This setup gives you full control over your data and a flexible workspace for notes, tasks, and diagrams. Ready to take it further? Explore Cloudflare Tunnels to access your server remotely.
Need help? Connect with me on LinkedIn or check out my technical writing portfolio.








