Deploy code-server on a VPS
Run VS Code in your browser — from any device, anywhere. Full editor, terminal, and extensions on your own server.
At a Glance
| Project | code-server by Coder |
| License | MIT |
| Recommended Plan | RamNode KVM2 (2 GB RAM) or higher |
| OS | Ubuntu 22.04 LTS |
| Default Port | 8080 (proxied to 443 via Nginx) |
| Authentication | Password (configurable) |
| Estimated Setup Time | 15–20 minutes |
Prerequisites
- A RamNode VPS — 2 GB RAM is a comfortable minimum; 1 GB is usable but may feel sluggish with multiple extensions
- Ubuntu 22.04 LTS (fresh install recommended)
- Root or sudo access
- A domain name pointed to your VPS IP (optional but recommended for Let's Encrypt)
- SSH access to your VPS
Update the System
sudo apt update && sudo apt upgrade -yReboot if the upgrade touched the kernel:
sudo rebootInstall code-server
The official install script detects your OS, downloads the correct binary, and registers a systemd service:
curl -fsSL https://code-server.dev/install.sh | shTip: Always review install scripts before piping to sh. Inspect it first with curl -fsSL https://code-server.dev/install.sh | less
Verify the installation:
code-server --versionConfigure code-server
code-server reads its configuration from a YAML file:
mkdir -p ~/.config/code-server
nano ~/.config/code-server/config.yamlbind-addr: 127.0.0.1:8080
auth: password
password: your-strong-password-here
cert: falsebind-addr: Listens only on localhost. Nginx handles incoming HTTPS traffic.
auth: Requires a password before granting access.
cert: TLS termination is handled by Nginx, not code-server.
Generate a random password with: openssl rand -base64 24
Enable and Start code-server
sudo systemctl enable --now code-server@$USERConfirm it is running:
sudo systemctl status code-server@$USERIf it shows failed, check the logs:
journalctl -u code-server@$USER -n 50 --no-pagerConfigure Nginx
sudo apt install nginx -yCreate a server block (replace code.yourdomain.com with your domain):
server {
listen 80;
server_name code.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_http_version 1.1;
}
}Important: The Upgrade and Connection headers are required for WebSocket support. code-server uses WebSockets heavily for real-time editor communication.
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxSecure with HTTPS
Option A — Let's Encrypt (Domain Required)
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d code.yourdomain.comTest automatic renewal:
sudo certbot renew --dry-runOption B — Self-Signed Certificate (No Domain)
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/code-server.key \
-out /etc/ssl/certs/code-server.crt \
-subj "/C=US/ST=State/L=City/O=Dev/CN=YOUR_VPS_IP"server {
listen 443 ssl;
server_name YOUR_VPS_IP;
ssl_certificate /etc/ssl/certs/code-server.crt;
ssl_certificate_key /etc/ssl/private/code-server.key;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_http_version 1.1;
}
}
server {
listen 80;
server_name YOUR_VPS_IP;
return 301 https://$host$request_uri;
}sudo nginx -t && sudo systemctl reload nginxConfigure the Firewall
sudo ufw allow 'Nginx Full'
sudo ufw deny 8080
sudo ufw enable
sudo ufw statusDenying port 8080 ensures traffic must go through Nginx rather than reaching code-server directly.
Access code-server
Open a browser and navigate to your domain:
- With Let's Encrypt:
https://code.yourdomain.com - With self-signed cert:
https://YOUR_VPS_IP(accept the browser warning)
Enter the password from ~/.config/code-server/config.yaml. After authenticating, VS Code loads in the browser.
Optional Configuration
Hashed Password
For better security, use an argon2-hashed password instead of plain text:
sudo apt install argon2 -y
echo -n 'your-password' | argon2 saltstring -eCopy the output hash and replace the password: line with hashed-password: in config.yaml. Both cannot be active at the same time.
Change the Default Shell
Open the Command Palette (Ctrl+Shift+P), search for "Open User Settings (JSON)", and add:
{
"terminal.integrated.defaultProfile.linux": "zsh"
}sudo apt install zsh -yTroubleshooting
Blank page or fails to load
Almost always a missing or incorrect WebSocket proxy header in Nginx. Verify the Upgrade and Connection headers are present and reload Nginx.
502 Bad Gateway
Nginx is running but cannot reach code-server. Check the service status and confirm it's binding to 127.0.0.1:8080.
sudo systemctl status code-server@$USERPassword not accepted
Re-check ~/.config/code-server/config.yaml. If using a hashed password, confirm the password: line has been removed. Restart after changes:
sudo systemctl restart code-server@$USERCertificate renewal fails
Certbot requires port 80 to be open and DNS A record pointing to your VPS IP. Run certbot renew --dry-run for detailed errors.
Maintenance
Updating code-server
The install script is idempotent — run it again to update:
curl -fsSL https://code-server.dev/install.sh | sh
sudo systemctl restart code-server@$USERMonitoring Resource Usage
code-server is lightweight at idle but can consume significant RAM with language servers or large builds:
htopIf you consistently run out of RAM, add swap as a safety buffer:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab