Bỏ qua đến nội dung chính

Lỗi thường gặp

Windows Defender đôi khi không tự allow Syncthing. Mở port manually:

Terminal window
# Run as Administrator
New-NetFirewallRule -DisplayName "Syncthing TCP" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 22000
New-NetFirewallRule -DisplayName "Syncthing UDP Discovery" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 21027
New-NetFirewallRule -DisplayName "Syncthing QUIC" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 22000

Cả 2 máy phải:

  1. Folder ID trùng nhau
  2. Sharing tab tick checkbox device kia

Verify Web UI → folder card → click “Edit” → tab Sharing → confirm.

Khi 2 máy edit cùng file lúc 1 máy offline:

hello.txt
hello.sync-conflict-20260502-150000-AMZHVWU.txt ← from device AMZHVWU (Laptop)

Resolve manually:

  1. Mở cả 2 versions, compare nội dung
  2. Quyết bản đúng:
    Terminal window
    # Vd nếu bản .sync-conflict-* đúng:
    Move-Item "hello.sync-conflict-*.txt" "hello.txt" -Force
  3. Hoặc merge nội dung từ cả 2

Avoid conflicts:

  • Đóng app trước khi switch máy
  • Đợi 30s sync xong rồi mới mở máy kia

Sau sync ~/.claude/.credentials.json 2 máy:

OAuth token có thể expire. Workaround:

Terminal window
# Re-login Claude Code trên máy đang fail
claude logout
claude login

Sau login, .credentials.json mới được sync về máy còn lại.

Folder card hiển thị X items “Out of Sync” mãi không clear:

Terminal window
# Check Syncthing log
tail -f ~/.config/syncthing/syncthing.log # Linux
# Windows: %APPDATA%\Syncthing\syncthing.log
# Common error: "permission denied" — file write protected
chmod -R u+w ~/path/to/folder # Linux
icacls "C:\path" /grant "$env:USERNAME:F" /T # Windows
Terminal window
# Check process
ps aux | grep syncthing # Linux
tasklist | findstr syncthing # Windows
# Restart
pkill -f syncthing && nohup syncthing serve --no-browser & # Linux
# Windows: kill task + start lại syncthing.exe

Auto-restart on crash — Linux setup:

Terminal window
# Use systemd user service
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/syncthing.service << 'EOF'
[Unit]
Description=Syncthing
After=network.target
[Service]
ExecStart=/usr/bin/syncthing serve --no-browser
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
EOF
systemctl --user daemon-reload
systemctl --user enable --now syncthing

Cần access từ network khác:

  1. Edit config.xml: change <address>127.0.0.1:8384</address>0.0.0.0:8384
  2. Set GUI password (Web UI → Settings → User & Password)
  3. Restart daemon

⚠ Security: open Web UI ra LAN cần password mạnh.