Development
    Browser IDE

    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

    Projectcode-server by Coder
    LicenseMIT
    Recommended PlanRamNode KVM2 (2 GB RAM) or higher
    OSUbuntu 22.04 LTS
    Default Port8080 (proxied to 443 via Nginx)
    AuthenticationPassword (configurable)
    Estimated Setup Time15–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
    1

    Update the System

    Update and upgrade
    sudo apt update && sudo apt upgrade -y

    Reboot if the upgrade touched the kernel:

    Reboot if needed
    sudo reboot
    2

    Install code-server

    The official install script detects your OS, downloads the correct binary, and registers a systemd service:

    Install code-server
    curl -fsSL https://code-server.dev/install.sh | sh

    Tip: Always review install scripts before piping to sh. Inspect it first with curl -fsSL https://code-server.dev/install.sh | less

    Verify the installation:

    Check version
    code-server --version
    3

    Configure code-server

    code-server reads its configuration from a YAML file:

    Create config file
    mkdir -p ~/.config/code-server
    nano ~/.config/code-server/config.yaml
    config.yaml
    bind-addr: 127.0.0.1:8080
    auth: password
    password: your-strong-password-here
    cert: false

    bind-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

    4

    Enable and Start code-server

    Enable and start
    sudo systemctl enable --now code-server@$USER

    Confirm it is running:

    Check status
    sudo systemctl status code-server@$USER

    If it shows failed, check the logs:

    View logs
    journalctl -u code-server@$USER -n 50 --no-pager
    5

    Configure Nginx

    Install Nginx
    sudo apt install nginx -y

    Create a server block (replace code.yourdomain.com with your domain):

    /etc/nginx/sites-available/code-server
    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.

    Enable site and reload
    sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl reload nginx
    6

    Secure with HTTPS

    Option A — Let's Encrypt (Domain Required)

    Install Certbot and issue certificate
    sudo apt install certbot python3-certbot-nginx -y
    sudo certbot --nginx -d code.yourdomain.com

    Test automatic renewal:

    Test renewal
    sudo certbot renew --dry-run

    Option B — Self-Signed Certificate (No Domain)

    Generate self-signed certificate
    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"
    Updated Nginx config for self-signed SSL
    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;
    }
    Test and reload
    sudo nginx -t && sudo systemctl reload nginx
    7

    Configure the Firewall

    UFW rules
    sudo ufw allow 'Nginx Full'
    sudo ufw deny 8080
    sudo ufw enable
    sudo ufw status

    Denying port 8080 ensures traffic must go through Nginx rather than reaching code-server directly.

    8

    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:

    Generate hashed password
    sudo apt install argon2 -y
    echo -n 'your-password' | argon2 saltstring -e

    Copy 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:

    settings.json
    {
      "terminal.integrated.defaultProfile.linux": "zsh"
    }
    Install zsh
    sudo apt install zsh -y

    Troubleshooting

    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.

    Check service
    sudo systemctl status code-server@$USER

    Password not accepted

    Re-check ~/.config/code-server/config.yaml. If using a hashed password, confirm the password: line has been removed. Restart after changes:

    Restart code-server
    sudo systemctl restart code-server@$USER

    Certificate 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:

    Update code-server
    curl -fsSL https://code-server.dev/install.sh | sh
    sudo systemctl restart code-server@$USER

    Monitoring Resource Usage

    code-server is lightweight at idle but can consume significant RAM with language servers or large builds:

    Monitor with htop
    htop

    If you consistently run out of RAM, add swap as a safety buffer:

    Add swap space
    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