Anki Sync Server: Flashcard Synchronization
Self-hosted Anki sync for spaced repetition. Sync flashcards across all devices.
Anki is the world’s most popular spaced repetition software, helping millions of students, professionals, and lifelong learners master everything from medical school curricula to foreign languages. This guide shows you how to deploy your own Anki sync server to keep your flashcard data private while syncing across all your devices.
What is Anki?
Anki is a powerful flashcard application that uses spaced repetition algorithms to optimize learning and long-term retention. Unlike traditional flashcard apps, Anki schedules reviews at scientifically-proven intervals to maximize memory consolidation while minimizing study time.
Why Self-Host Anki Sync Server?
Privacy and Data Ownership:
- AnkiWeb free tier: 300MB storage limit, data stored on third-party servers
- Self-hosted: Unlimited storage, complete data control
- No sharing of study patterns or learning data
- Full compliance with institutional data policies
Unlimited Storage:
- AnkiWeb paid tier: $27/year for increased storage
- Self-hosted: Only limited by your server capacity
- Store high-resolution images, audio files, videos
- Large medical image decks (radiology, pathology)
- Language learning with extensive audio
Performance Benefits:
- Faster sync speeds on local network
- No dependency on external service availability
- Reduced latency for large deck syncs
- Control over server resources and optimization
Institutional and Team Use:
- Deploy for entire organization
- No per-user subscription costs
- Custom backup and retention policies
- Integration with existing authentication systems
How Spaced Repetition Works
Anki implements the SuperMemo SM-2 algorithm:
- New cards: Shown for first time
- Learning cards: Recently introduced, shown frequently
- Review cards: Mastered cards shown at increasing intervals
- Lapsed cards: Cards you forgot, re-entered learning phase
Example Learning Timeline:
Day 1: Study new card "What is Docker?"
Day 2: Review (if correct, interval increases)
Day 4: Review (interval doubles)
Day 8: Review
Day 16: Review
Day 32: Review
...continues with increasing intervals This scientifically-proven approach ensures:
- 90%+ retention rates
- Minimal study time for maximum retention
- Automatic difficulty adjustment
- Long-term memory consolidation
Prerequisites
Before deploying your Anki sync server:
System Requirements:
- Docker and Docker Compose installed
- 512MB RAM minimum (1GB+ recommended)
- 1 CPU core (adequate for personal use)
- 10GB+ storage (grows with deck content)
- Ubuntu 22.04 LTS or similar Linux distribution
Software Requirements:
- Anki Desktop application (Windows, Mac, or Linux)
- Anki Mobile app (iOS or Android) - optional
- Basic command-line knowledge
- Understanding of Docker concepts
Network Requirements:
- Static local IP or DHCP reservation
- Port 27701 available (default sync port)
- Optional: Domain name for remote access
Understanding Anki Architecture
Components:
Anki Desktop/Mobile:
- Client application for studying
- Creates and edits flashcards
- Tracks study statistics
- Initiates sync with server
Sync Server:
- Stores deck data and media
- Handles synchronization requests
- Manages user accounts
- Coordinates cross-device sync
Database:
- SQLite-based storage
- Stores cards, reviews, statistics
- Media files (images, audio, video)
- User preferences and settings
Sync Flow:
Anki Desktop (Computer)
|
v
[Sync Server] Port 27701
|
v
[Database Storage]
|
v
Anki Mobile (Phone/Tablet) Installation and Deployment
Step 1: Choose Sync Server Implementation
Two popular options exist:
anki-sync-server (Official):
- Official implementation by Anki developers
- Python-based
- Stable and well-maintained
- Recommended for most users
anki-sync-server-rs (Rust):
- Community implementation in Rust
- Higher performance
- Lower resource usage
- Good for resource-constrained environments
This guide uses the official Python implementation.
Step 2: Directory Preparation
Create project directory:
# Create directory structure
mkdir -p ~/anki-sync-server/data
# Set permissions
chmod -R 755 ~/anki-sync-server Step 3: Docker Compose Configuration
Create ~/anki-sync-server/docker-compose.yml:
version: '3.8'
services:
anki-sync-server:
image: ankicommunity/anki-sync-server:latest
container_name: anki-sync-server
restart: unless-stopped
environment:
# Server Configuration
ANKISYNCD_HOST: 0.0.0.0
ANKISYNCD_PORT: 27701
# Authentication
ANKISYNCD_AUTH_DB_PATH: /data/auth.db
ANKISYNCD_SESSION_DB_PATH: /data/session.db
# Data Storage
ANKISYNCD_DATA_ROOT: /data
# Optional: Enable HTTPS (requires certificates)
# ANKISYNCD_USE_HTTPS: "true"
# ANKISYNCD_CERT_FILE: /certs/cert.pem
# ANKISYNCD_KEY_FILE: /certs/key.pem
ports:
- "27701:27701"
volumes:
- ./data:/data
networks:
- anki-network
networks:
anki-network:
driver: bridge Configuration Notes:
- Port 27701: Standard Anki sync port
- Volume
./data: Stores all user data and decks - Restart policy ensures availability after reboots
Alternative: Rust Implementation (Optional)
For higher performance, use the Rust version:
version: '3.8'
services:
anki-sync-server:
image: ghcr.io/ankicommunity/anki-sync-server-rs:latest
container_name: anki-sync-server
restart: unless-stopped
environment:
ANKISYNCD_PORT: 27701
ANKISYNCD_HOST: 0.0.0.0
MAX_SYNC_PAYLOAD_MEGS: 100
ports:
- "27701:27701"
volumes:
- ./data:/data
networks:
- anki-network
networks:
anki-network:
driver: bridge Step 4: Deploy Sync Server
# Navigate to project directory
cd ~/anki-sync-server
# Pull Docker image
docker-compose pull
# Start service
docker-compose up -d
# Verify startup
docker-compose logs -f Look for successful startup message:
Anki Sync Server started on 0.0.0.0:27701 Step 5: Verify Deployment
# Check container status
docker-compose ps
# Should show "Up"
# Check logs
docker-compose logs anki-sync-server
# Test network accessibility
curl http://YOUR-SERVER-IP:27701
# Should return Anki sync server response Step 6: Create User Accounts
Add Your First User:
# Enter container
docker exec -it anki-sync-server sh
# Add user (replace username and password)
ankisyncctl adduser YOUR-USERNAME
# Enter password when prompted
# Exit container
exit Alternative: Command-line User Creation:
docker exec -it anki-sync-server ankisyncctl adduser YOUR-USERNAME Create Multiple Users:
# Add family members or team members
docker exec -it anki-sync-server ankisyncctl adduser alice
docker exec -it anki-sync-server ankisyncctl adduser bob
docker exec -it anki-sync-server ankisyncctl adduser charlie List Users:
docker exec -it anki-sync-server ankisyncctl lsuser Delete User:
docker exec -it anki-sync-server ankisyncctl deluser USERNAME Desktop Client Configuration
Anki Desktop Setup (Windows, Mac, Linux)
Install Anki Desktop:
- Download from apps.ankiweb.net
- Install latest stable version (2.1.60+)
- Launch Anki
Configure Sync Server:
Anki 2.1.60+ (newest versions):
- Open Anki
- Go to Tools → Preferences → Network
- Self-hosted sync server section:
- Enable: Check “Use custom sync server”
- Sync URL:
http://YOUR-SERVER-IP:27701/ - Media URL:
http://YOUR-SERVER-IP:27701/msync
- Click OK
Older Anki Versions (2.1.28-2.1.59):
Create addon file to configure server:
- Tools → Add-ons → View Files
- Create folder:
ankisyncd - Inside folder, create
__init__.py:
import anki.sync
# Configure sync server
anki.sync.SYNC_URL = "http://YOUR-SERVER-IP:27701/"
anki.sync.SYNC_MEDIA_URL = "http://YOUR-SERVER-IP:27701/msync" - Restart Anki
First Sync
Initial Synchronization:
- Click Sync button (top right)
- Enter credentials:
- AnkiWeb ID: YOUR-USERNAME (from earlier setup)
- Password: Your password
- First sync prompt:
- “Upload to sync server” (if you have existing decks)
- “Download from sync server” (if server has your decks)
- Wait for sync to complete
Subsequent Syncs:
- Click Sync button anytime
- Automatic sync on startup (if enabled in preferences)
- Automatic sync on close (if enabled)
Sync Settings Optimization
Tools → Preferences → Network:
Synchronization:
├─ Sync on profile open: Yes (recommended)
├─ Sync on profile close: Yes (recommended)
├─ Sync media: Yes (includes images/audio)
├─ Check for updates: No (optional)
└─ Periodically sync media: Yes Media Sync: Large media libraries take time on first sync:
- Medical images: 1-2 hours for 10GB
- Language audio: 30-60 minutes for 5GB
- Subsequent syncs: Only changed files
Mobile App Configuration
iOS (AnkiMobile)
Purchase and Install:
- AnkiMobile costs $24.99 (one-time purchase)
- Download from iOS App Store
- Install and launch
Configure Sync Server:
- Open AnkiMobile
- Tap Settings (gear icon)
- Tap Synchronization
- Sync Server section:
- Custom sync server: Enable
- Sync URL:
http://YOUR-SERVER-IP:27701/ - Media URL:
http://YOUR-SERVER-IP:27701/msync/
- Return to main screen
First Sync:
- Tap Sync button
- Enter credentials (username/password)
- Choose sync direction:
- Download from server (recommended for first mobile sync)
- Wait for completion
Android (AnkiDroid)
Install AnkiDroid:
- Free on Google Play Store
- Install and launch
Configure Custom Sync Server:
- Open AnkiDroid
- Tap menu (three lines) → Settings
- Tap Advanced
- Scroll to Custom sync server
- Enable custom sync server
- Configure:
- Sync URL:
http://YOUR-SERVER-IP:27701/ - Media sync URL:
http://YOUR-SERVER-IP:27701/msync/
- Sync URL:
- Back to main screen
First Sync:
- Tap Sync button (circular arrows)
- Enter AnkiWeb credentials:
- ID: YOUR-USERNAME
- Password: Your password
- Choose “Download from AnkiWeb” (for first sync)
- Wait for sync completion
Note: AnkiDroid may require HTTP instead of HTTPS for local servers. If using a domain with SSL, ensure certificate is valid.
Deck Organization Best Practices
Creating Effective Decks
Deck Structure Example (Medical Student):
Medicine
├── Anatomy
│ ├── Cardiology
│ ├── Neurology
│ └── Musculoskeletal
├── Physiology
│ ├── Cardiovascular
│ └── Respiratory
├── Pharmacology
│ ├── Antibiotics
│ └── Cardiovascular Drugs
└── Clinical Skills
├── Physical Exam
└── Differential Diagnosis Language Learning Example:
Spanish
├── Vocabulary
│ ├── Common Words (1000)
│ ├── Verbs
│ └── Phrases
├── Grammar
│ ├── Verb Conjugation
│ └── Sentence Structure
└── Pronunciation
└── Audio Practice Card Creation Tips
Effective Card Format:
Good Card (Simple, focused):
Q: Capital of France?
A: Paris Bad Card (Too complex):
Q: What are the capitals of France, Germany, and Spain, and what are their populations?
A: Paris (2.1M), Berlin (3.7M), Madrid (3.2M) Use Cloze Deletions:
Docker is a {{c1::containerization}} platform that allows you to {{c2::package applications}} with their dependencies. Add Images for Visual Learners:
Q: [Image of heart diagram]
What structure is indicated by the arrow?
A: Left ventricle Include Audio for Languages:
Q: How do you pronounce "croissant"?
A: [Audio file: croissant.mp3]
Translation: Crescent roll Shared Deck Import
Download Shared Decks:
- Visit ankiweb.net/shared/decks
- Search for topic (e.g., “MCAT”, “Spanish”, “Programming”)
- Download .apkg file
- Anki Desktop → File → Import
- Select downloaded file
- Sync to propagate to all devices
Popular Shared Decks:
- AnKing Medical Deck (30,000+ cards)
- Ultimate Geography (4,700+ countries/capitals)
- Core 2K/6K/10K Japanese Vocabulary
- Programming concepts and syntax
- Professional certifications (AWS, CCNA, etc.)
User Management
Adding Users
Family or Team Setup:
# Add family members
docker exec -it anki-sync-server ankisyncctl adduser mom
docker exec -it anki-sync-server ankisyncctl adduser dad
docker exec -it anki-sync-server ankisyncctl adduser daughter
docker exec -it anki-sync-server ankisyncctl adduser son
# Each user gets:
# - Separate deck storage
# - Individual study statistics
# - Private flashcard content User Data Isolation
Each user’s data is completely isolated:
- Separate SQLite databases
- Individual media directories
- Private study statistics
- No cross-user data access
Data Structure:
~/anki-sync-server/data/
├── auth.db (authentication database)
├── session.db (active sessions)
├── collections/
│ ├── user1/
│ │ ├── collection.anki2 (deck database)
│ │ └── media/ (images, audio)
│ ├── user2/
│ └── user3/ Password Management
Change User Password:
# Change password for existing user
docker exec -it anki-sync-server ankisyncctl passwd USERNAME
# Enter new password when prompted Password Policy Recommendations:
- Minimum 12 characters
- Mix of letters, numbers, symbols
- Unique password (not reused)
- Store in password manager
Backup Procedures
What to Backup
Critical data to preserve:
User Collections:
/data/collections/: All user decks and study data- Priority: CRITICAL
Authentication Database:
/data/auth.db: User credentials- Priority: HIGH
Media Files:
/data/collections/*/media/: Images, audio, video- Priority: HIGH (often largest component)
Session Database:
/data/session.db: Active login sessions- Priority: LOW (regenerates)
Automated Backup Script
Create ~/anki-sync-server/backup.sh:
#!/bin/bash
# Configuration
BACKUP_DIR="/backups/anki"
DATE=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=30
ANKI_DATA="$HOME/anki-sync-server/data"
# Create backup directory
mkdir -p $BACKUP_DIR
echo "Starting Anki sync server backup: $(date)"
# Stop container for consistent backup (optional)
# cd ~/anki-sync-server
# docker-compose stop anki-sync-server
# Backup entire data directory
echo "Backing up Anki data..."
tar -czf $BACKUP_DIR/anki-data-$DATE.tar.gz -C $HOME/anki-sync-server data
if [ $? -eq 0 ]; then
echo "Backup completed successfully"
else
echo "Backup FAILED"
exit 1
fi
# Restart container
# docker-compose start anki-sync-server
# Backup docker-compose configuration
cp ~/anki-sync-server/docker-compose.yml $BACKUP_DIR/docker-compose-$DATE.yml
# Calculate backup size
BACKUP_SIZE=$(du -h $BACKUP_DIR/anki-data-$DATE.tar.gz | cut -f1)
echo "Backup size: $BACKUP_SIZE"
# Remove old backups
echo "Cleaning old backups..."
find $BACKUP_DIR -name "anki-data-*.tar.gz" -mtime +$RETENTION_DAYS -delete
find $BACKUP_DIR -name "docker-compose-*.yml" -mtime +$RETENTION_DAYS -delete
echo "Backup completed: $(date)"
echo "Location: $BACKUP_DIR/anki-data-$DATE.tar.gz" Make Executable:
chmod +x ~/anki-sync-server/backup.sh Test Backup:
~/anki-sync-server/backup.sh Schedule Automated Backups:
# Edit crontab
crontab -e
# Add daily backup at 3 AM
0 3 * * * /home/user/anki-sync-server/backup.sh >> /var/log/anki-backup.log 2>&1 Disaster Recovery
Restore from Backup:
# Stop sync server
cd ~/anki-sync-server
docker-compose down
# Backup current data (safety measure)
mv data data.old
# Extract backup
tar -xzf /backups/anki/anki-data-YYYYMMDD_HHMMSS.tar.gz -C ~/anki-sync-server
# Restore permissions
chmod -R 755 ~/anki-sync-server/data
# Start sync server
docker-compose up -d
# Verify restoration
docker-compose logs -f Verify Data Integrity:
# Check user databases exist
ls -lh ~/anki-sync-server/data/collections/
# Verify user authentication
docker exec -it anki-sync-server ankisyncctl lsuser Export Individual Decks
From Anki Desktop:
- File → Export
- Select deck to export
- Format: Anki Deck Package (.apkg)
- Include: All cards, scheduling information, media
- Save to secure location
This creates portable backup of specific decks.
Troubleshooting
Common Issues and Solutions
Issue: Cannot Connect to Sync Server
Diagnostics:
# Check container running
docker-compose ps
# Check logs
docker-compose logs anki-sync-server
# Test network connectivity
curl http://YOUR-SERVER-IP:27701
# Check firewall
sudo ufw status Solutions:
- Ensure container running:
docker-compose up -d - Allow port through firewall:
sudo ufw allow 27701/tcp - Verify correct IP address in client configuration
- Check no other service using port 27701:
sudo netstat -tlnp | grep 27701
Issue: Authentication Failed
Solutions:
- Verify credentials:
# List users
docker exec -it anki-sync-server ankisyncctl lsuser - Reset password:
docker exec -it anki-sync-server ankisyncctl passwd USERNAME - Check auth database:
# Verify database exists
ls -lh ~/anki-sync-server/data/auth.db - Recreate user if needed:
docker exec -it anki-sync-server ankisyncctl deluser USERNAME
docker exec -it anki-sync-server ankisyncctl adduser USERNAME Issue: Sync Fails with “Conflict” Error
Solutions:
- Force sync direction:
- Desktop: Tools → Preferences → Network → Sync → Upload/Download
- Mobile: Sync settings → Full sync → Upload/Download
- Ensure only one device syncing at a time
- Check adequate storage space on server
Issue: Media Files Not Syncing
Solutions:
Verify media sync enabled:
- Desktop: Tools → Preferences → Network → Sync media: Yes
- Mobile: Settings → Sync media: Enabled
Check disk space:
df -h ~/anki-sync-server/data - Verify media directory permissions:
ls -lh ~/anki-sync-server/data/collections/USERNAME/media/ - Manual media sync:
- Anki Desktop: Tools → Check Media
- Fix any issues reported
- Sync again
Issue: Slow Sync Performance
Solutions:
- Initial sync is always slow (full deck transfer)
- Subsequent syncs only transfer changes (fast)
- Optimize large media files:
- Compress images (JPG instead of PNG)
- Use lower bitrate audio files
- Resize images to reasonable dimensions
- Sync over wired connection when possible
- Increase container resources if constrained
Issue: Lost Sync Button or Sync Not Working
Solutions:
- Tools → Preferences → Network → Verify server URLs correct
- Restart Anki Desktop
- Check internet/network connectivity
- Verify sync server container running
- Review sync server logs for errors
Remote Access Configuration
Option 1: Tailscale VPN (Recommended)
Secure access from anywhere without port forwarding.
Install Tailscale on Server:
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up Get Tailscale IP:
tailscale ip -4
# Returns: 100.x.y.z Configure Clients:
- Install Tailscale on all devices (desktop, mobile)
- Login to same account
- Update Anki sync URL to Tailscale IP:
http://100.x.y.z:27701/
Benefits:
- No port forwarding needed
- Encrypted VPN tunnel
- Works from any network
- Free for personal use
Option 2: Reverse Proxy with SSL
For public domain access with HTTPS.
Using Caddy:
Create /opt/caddy/Caddyfile:
anki.yourdomain.com {
reverse_proxy YOUR-SERVER-IP:27701
} Configure Anki Clients:
- Sync URL:
https://anki.yourdomain.com/ - Media URL:
https://anki.yourdomain.com/msync/
DNS Configuration:
- Create A record:
anki.yourdomain.com→ Your public IP - Forward ports 80 and 443 to server
Security Considerations:
- Use strong passwords
- Consider rate limiting
- Monitor access logs
- Regular security updates
Advanced Configuration
Performance Tuning
Increase Max Payload Size:
For users with very large decks:
environment:
MAX_SYNC_PAYLOAD_MEGS: 500 # Default is 100MB Resource Limits:
services:
anki-sync-server:
# ... existing config ...
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 256M Multi-User Organization
For Families:
- Each family member has separate account
- Private study data
- Shared server infrastructure
- Coordinate backup schedules
For Study Groups:
- Individual accounts for each member
- Share deck files manually (export/import)
- Collaborative deck development
- Group study statistics tracking
For Institutions:
- Departmental deployment
- Centralized backup management
- User provisioning workflows
- Integration with directory services
Study Tips and Best Practices
Effective Use of Spaced Repetition
Daily Study Routine:
- Review all due cards (reviews first priority)
- Study new cards (20-30 per day recommended)
- Use “Hard”, “Good”, “Easy” ratings honestly
- Don’t skip days (consistency crucial)
Optimize Deck Settings:
- New cards per day: 20-30 (sustainable long-term)
- Maximum reviews per day: Unlimited (must clear due cards)
- Learning steps: 1m 10m 1d (or customize)
- Graduating interval: 3 days
- Easy interval: 4 days
Avoid Common Mistakes:
- Don’t create cards that are too complex
- Don’t study more than 1-2 hours per day (burnout risk)
- Don’t skip reviews (breaks spaced repetition)
- Don’t ignore “Hard” button (use full rating scale)
Mobile Study Workflow
Best Practices:
- Sync before studying
- Study during commute, breaks, downtime
- Sync after studying
- Enable offline mode for subway/airplane
- Use audio cards for walking/driving (careful)
Mobile-Specific Settings:
- AnkiMobile: Settings → Study → Tap to reveal
- AnkiDroid: Settings → Reviewing → Gesture controls
- Optimize for one-handed use
- Use night mode for evening study
Next Steps
Immediate Actions
After completing setup:
- Create user account and test sync from desktop
- Import first deck or create practice deck
- Sync to mobile device and verify
- Set up automated backups and test restore
- Study consistently for 7 days to establish habit
Expansion Ideas
Personal Learning:
- Medical school preparation (AnKing deck)
- Language acquisition (Core vocabulary)
- Professional certification study
- Hobby knowledge building
Family Learning:
- Children’s education support
- Homeschool curriculum reinforcement
- Family trivia and games
- Shared knowledge building
Professional Development:
- Technical skill mastery
- Industry certifications
- Product knowledge training
- Compliance and safety training
Conclusion
You now have a private, self-hosted Anki sync server providing unlimited storage and complete data control. Combined with Anki’s proven spaced repetition algorithm, you have a powerful foundation for lifelong learning across all your devices.
Key Achievements
- Self-hosted sync server with unlimited storage
- Multi-device synchronization (desktop + mobile)
- User account management
- Automated backup system
- Remote access configured
- Privacy-preserving architecture
Resources
Official Resources:
- apps.ankiweb.net: Anki desktop downloads
- docs.ankiweb.net: Complete documentation
- ankiweb.net/shared: Shared deck library
Community Support:
- r/Anki: Reddit community (140k+ members)
- Anki forums: Official discussion boards
- YouTube: Study technique tutorials
Recommended Decks:
- Medical: AnKing, Sketchy, Pixorize
- Languages: Core 2K/6K, Grammar decks
- Tech: AWS, Programming languages, Networking
- General: Ultimate Geography, History timelines
Start with small, achievable goals. Study 20 new cards daily, review all due cards, and maintain consistency. The spaced repetition algorithm will handle the rest, optimizing your learning for maximum long-term retention with minimum time investment.
Welcome to evidence-based, self-directed learning!