Self-host ComfyUI on a VPS or GPU server
ComfyUI is the node-based Stable Diffusion front-end favored by power users. Running it on a remote machine — instead of a local desktop GPU — lets you generate images from any device, but you have to do it right: GPU sizing matters, and an exposed UI is a wide-open backdoor.
Hard truth about CPU-only ComfyUI
ComfyUI can run on CPU. It just shouldn't. A single 1024×1024 SDXL image takes 8-15 minutes on a fast CPU, ~30 seconds on a consumer GPU, < 10 seconds on an enterprise GPU. CPU-only is fine for testing the install, useless for actual workflows.
What this guide assumes: you have access to a GPU. Either:
- A local desktop GPU exposed via Tailscale / WireGuard for remote access.
- A rented GPU VPS (Vast.ai, RunPod, Lambda, certain Hetzner / OVH dedicated boxes).
- A cloud GPU instance (cheap on Vast.ai when spot pricing is good, expensive on AWS).
Sizing the GPU
| Model class | VRAM needed | Example GPU |
|---|---|---|
| SD 1.5 | 4 GB | GTX 1060, RTX 3050 |
| SDXL | 8-12 GB | RTX 3060 12GB, 4070 |
| SDXL + ControlNet + LoRA | 12-16 GB | RTX 4070 Ti |
| FLUX.1 dev (fp16) | 24 GB | RTX 3090, 4090 |
| FLUX.1 dev (fp8 quantized) | 12-16 GB | RTX 4070 Ti, 4080 |
Install
sudo apt update
sudo apt install -y python3 python3-venv python3-pip git ffmpeg
# Verify NVIDIA driver + CUDA
nvidia-smi
Clone the repo and set up a venv:
cd /opt
sudo git clone https://github.com/comfyanonymous/ComfyUI.git
sudo chown -R $USER:$USER ComfyUI
cd ComfyUI
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
# PyTorch with CUDA — match your CUDA toolkit version
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
Download models
ComfyUI looks for models under models/:
cd /opt/ComfyUI
# Example: a base SDXL checkpoint
wget -O models/checkpoints/sd_xl_base_1.0.safetensors \
https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
Many models require accepting a license on Hugging Face first. Generate an HF access token and pass it via huggingface-cli login before downloading gated files.
First run
source /opt/ComfyUI/venv/bin/activate
cd /opt/ComfyUI
python main.py --listen 127.0.0.1 --port 8188
Note --listen 127.0.0.1 — bound to localhost only. ComfyUI has no authentication. Anyone reaching the port can use your GPU and overwrite your files.
systemd unit
sudo nano /etc/systemd/system/comfyui.service
[Unit]
Description=ComfyUI
After=network.target
[Service]
Type=simple
User=comfyuser
Group=comfyuser
WorkingDirectory=/opt/ComfyUI
ExecStart=/opt/ComfyUI/venv/bin/python main.py --listen 127.0.0.1 --port 8188
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now comfyui
Remote access: pick one (do not skip)
You have a UI on 127.0.0.1:8188. Three good ways to reach it from elsewhere, in order of preference:
Option A — WireGuard / Tailscale (best)
Run ComfyUI bound only to localhost or to the VPN interface IP. Access it through the tunnel. Nothing public. See our WireGuard install for the basics; Tailscale is even simpler.
Option B — Nginx + HTTPS + Basic auth
If you must expose the UI publicly, put Nginx in front with HTTPS and a basic-auth gate:
sudo apt install -y apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd-comfy comfyadmin
sudo nano /etc/nginx/sites-available/comfy
server {
listen 80;
server_name comfy.example.com;
location /.well-known/acme-challenge/ { root /var/www/html; }
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd-comfy;
# Optional IP allowlist on top of basic auth
allow YOUR.HOME.IP;
deny all;
proxy_pass http://127.0.0.1:8188;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
client_max_body_size 100M;
}
}
sudo certbot --nginx -d comfy.example.com --redirect
Option C — SSH tunnel
The simplest one-off pattern: ssh -L 8188:127.0.0.1:8188 user@your-server, then open http://localhost:8188 in your browser. Nothing publicly exposed, no extra config on the server.
What about Docker?
A Compose-based ComfyUI works, but GPU passthrough on Docker adds friction (nvidia-container-toolkit, runtime flags, version pinning). On a single-purpose GPU host the native install is simpler. On multi-tenant hosts (running n8n + ComfyUI + Ollama all together) Docker pays back. Community Docker images exist; pin to a specific tag.
Custom nodes
ComfyUI's strength is its extension ecosystem. Install the ComfyUI Manager:
cd /opt/ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
sudo systemctl restart comfyui
Reload the UI; the Manager appears as a menu. Treat it like a package manager — only install nodes you trust. Custom nodes run arbitrary Python with full filesystem access; a malicious one can exfiltrate your models or worse.
Sharing the same models with other tools
If you also run Automatic1111 / Forge / SD.Next on the same machine, set up shared symlinks instead of duplicating multi-GB files:
ln -s /opt/SharedModels/checkpoints /opt/ComfyUI/models/checkpoints
ln -s /opt/SharedModels/loras /opt/ComfyUI/models/loras
Common ComfyUI mistakes
"CUDA out of memory"
The model + workflow doesn't fit in your GPU VRAM. Use fp8/quantized variants, drop the resolution, or split into multiple smaller passes (img2img upscale).
"Generation is slow even on a good GPU"
You're running the unquantized FLUX.1 dev on a 16 GB GPU — it spills to system RAM. Switch to fp8 or GGUF-quantized weights.
"UI loads but workflows fail silently"
Almost always a missing model file (referenced by name in the workflow, not present in models/checkpoints/) or a missing custom node. Watch the server log; the error is verbose.
"ComfyUI updated and broke everything"
Pin via git: stay on a known-good tag (git checkout v0.2.x) rather than tracking master. Update on a schedule, not whenever you happen to git pull.
Don't need GPU but want the rest of the stack?
For Ollama (LLMs) and other CPU-friendly AI workloads, Inferno's high-RAM plans run smoothly. ComfyUI specifically needs a GPU — rent one through a GPU-focused provider and use Inferno for the rest of your self-hosted stack.
What to do next
- Ollama install for LLM workloads.
- Open WebUI as the chat front-end.
- WireGuard for safe remote access to GPU boxes.
- Docker hardening if you containerize.
Author: Daniel Ferro — Lisbon. Last tested: 2026-05-22 on ComfyUI 0.2.x with RTX 3090, Ubuntu 22.04, CUDA 12.1.