Technology Encyclopedia Home >Deploy code-server on a Cloud Server — Access VS Code from Any Browser, Anywhere

Deploy code-server on a Cloud Server — Access VS Code from Any Browser, Anywhere

There's a situation every developer knows: you're away from your main machine, you need to fix something in a project, and whatever computer you have access to doesn't have your dev environment set up.

code-server solves this. It runs VS Code on a cloud server and serves it through a browser. You get the full editor — extensions, terminal, git integration, IntelliSense — from any browser on any device. I use it when I'm traveling or on a tablet, and it feels identical to running VS Code locally.

Lighthouse shortcut: If you want a browser-based IDE without the manual code-server setup, Lighthouse has a Theia Cloud IDE application image — it's a VS Code-compatible browser IDE that's pre-installed and ready when the server provisions. This guide covers code-server (for those who want the full VS Code compatibility and extension ecosystem); the Theia image is worth knowing if you want zero-setup browser IDE access.

I run code-server on Tencent Cloud Lighthouse. The 2 GB RAM / 2 vCPU plan works for most development work; 4 GB RAM for memory-intensive language servers. Lighthouse's OrcaTerm browser terminal gives you a backup shell access path independent of code-server — if code-server is updating or restarting, you can still manage the server. The always-on infrastructure means your development environment is available from any device, anywhere.


Table of Contents

  1. Why code-server on a VPS?
  2. What You Need
  3. Part 1: Install code-server
  4. Part 2: Secure with Password and HTTPS
  5. Part 3: Set Up Nginx with SSL
  6. Part 4: Configure Your Development Environment
  7. Part 5: Access from Mobile Devices
  8. The Thing That Tripped Me Up
  9. Troubleshooting
  10. Summary

  • Key Takeaways
  • Use the appropriate Lighthouse application image to skip manual installation steps where available
  • Lighthouse snapshots provide one-click full-server backup before major changes
  • OrcaTerm browser terminal lets you manage the server from any device
  • CBS cloud disk expansion handles growing storage needs without server migration
  • Console-level firewall + UFW = two independent protection layers

Why code-server on a VPS? {#why}

Running VS Code on a cloud server offers a specific kind of flexibility:

  • Device-independent — code from any browser: laptop, tablet, Chromebook, borrowed computer
  • Consistent environment — your tools, extensions, and settings are always available
  • Remote development — files and processes run server-side, no latency for file operations
  • Background processes — long-running builds, downloads, or servers keep running after you close the browser
  • Low-powered devices work fine — the server does the computing; the client just renders UI
  • Team-shared environments — multiple users can have their own code-server instances on one server

The one adjustment: keyboard shortcuts behave slightly differently in a browser (the browser intercepts some shortcuts). After a day or two, you adapt.


What You Need {#prerequisites}

Requirement Details
Server Ubuntu 22.04, 2 GB+ RAM
Domain Recommended for HTTPS setup
Browser Any modern browser; Firefox and Chrome work best
Ports open 80, 443 (via Nginx), or 8080 direct

Part 1: Install code-server {#part-1}

1.1 — Download and Install

The easiest installation method is the official install script:

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

This detects your OS and installs the appropriate package. Alternatively, download a specific version:

VERSION="4.22.1"
curl -fOL https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb
sudo dpkg -i code-server_${VERSION}_amd64.deb

1.2 — Enable and Start as a Service

sudo systemctl enable --now code-server@$USER
sudo systemctl status code-server@$USER

1.3 — Check the Default Configuration

cat ~/.config/code-server/config.yaml

Default contents:

bind-addr: 127.0.0.1:8080
auth: password
password: someauto-generatedpassword
cert: false

The auto-generated password is what you'll use to log in. Change it to something you'll remember:

nano ~/.config/code-server/config.yaml

Update the password field:

password: your-strong-password-here

Restart to apply:

sudo systemctl restart code-server@$USER

Part 2: Secure with Password and HTTPS {#part-2}

code-server supports built-in TLS, but using Nginx as a reverse proxy gives you more flexibility and standard Let's Encrypt certificate management.

Leave bind-addr: 127.0.0.1:8080 as is — code-server only listens locally. Nginx handles the public-facing SSL.


Part 3: Set Up Nginx with SSL {#part-3}

3.1 — Install Nginx and Certbot

sudo apt install -y nginx certbot python3-certbot-nginx

3.2 — Point Your Domain to the Server

Add an A record in your DNS:

code.yourdomain.com  →  YOUR_SERVER_IP

3.3 — Create the Nginx Site Configuration

sudo nano /etc/nginx/sites-available/code-server
server {
    listen 80;
    server_name code.yourdomain.com;
    
    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_set_header Accept-Encoding gzip;
    }
}

The Upgrade and Connection headers are required for WebSocket support — code-server's terminal and live preview features use WebSockets.

3.4 — Enable the Site and Get SSL

sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

sudo certbot --nginx -d code.yourdomain.com

Follow the Certbot prompts. Select option 2 (redirect HTTP to HTTPS).

3.5 — Verify

Navigate to https://code.yourdomain.com. You'll see a password prompt. Enter the password from your config.yaml. The VS Code interface loads in the browser.


Part 4: Configure Your Development Environment {#part-4}

4.1 — Install Node.js

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt install -y nodejs

4.2 — Install Python

sudo apt install -y python3 python3-pip python3-venv

4.3 — Install Extensions

Open the browser VS Code, press Ctrl+Shift+X (or Cmd+Shift+X on Mac), and install your usual extensions. They're stored on the server and persist across sessions.

Recommended for most developers:

  • ESLint / Prettier — JavaScript formatting
  • Python (Microsoft) — Python language server
  • GitLens — Git history visualization
  • Remote Repositories — Browse GitHub repos without cloning
  • Dracula Official or your preferred theme

4.4 — Set Up Git

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# Add GitHub SSH key
ssh-keygen -t ed25519 -C "code-server-vps"
cat ~/.ssh/id_ed25519.pub
# Add this public key to GitHub → Settings → SSH Keys

4.5 — Configure the Integrated Terminal

The terminal in code-server runs as your server user. Install your preferred shell tools:

# zsh (optional)
sudo apt install -y zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# tmux for persistent sessions
sudo apt install -y tmux

Part 5: Access from Mobile Devices {#part-5}

code-server works in mobile browsers with some limitations:

On iPad/iPhone:

  • Use Safari or Chrome
  • Add to Home Screen for full-screen experience
  • Hardware keyboard works well; on-screen keyboard is usable for light edits

On Android:

  • Chrome works best
  • Add to Home Screen for app-like experience
  • External Bluetooth keyboard significantly improves usability

Tip: The Ctrl key issue on mobile can be worked around by using the built-in VS Code command palette (F1 or tap the hamburger menu) for most operations that normally use keyboard shortcuts.


The Thing That Tripped Me Up {#gotcha}

After setup, the VS Code terminal would disconnect randomly after a few minutes of inactivity.

The cause: Nginx's default proxy timeouts were killing the WebSocket connection.

The fix: Add timeout settings to your Nginx configuration:

server {
    # ... existing config ...

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_set_header Accept-Encoding gzip;
        
        # Prevent WebSocket timeout
        proxy_read_timeout 7d;
        proxy_send_timeout 7d;
        proxy_connect_timeout 7d;
    }
}
sudo nginx -t && sudo systemctl reload nginx

After this change, terminal sessions and browser-based connections stay alive indefinitely.


Troubleshooting {#troubleshooting}

Issue Likely Cause Fix
Password prompt keeps appearing Cookie not persisting Check browser is allowing cookies for the domain
Terminal disconnects WebSocket timeout Add proxy_read_timeout 7d to Nginx config
Extensions not loading Network issue or slow install Wait and retry; check journalctl -u code-server
502 Bad Gateway code-server not running sudo systemctl start code-server@$USER
Can't open ports in terminal UFW blocking Check UFW; use the VS Code port forwarding feature
High memory usage Language server (e.g., Java LSP) Disable heavy language extensions when not needed
Keyboard shortcuts not working Browser intercepting keys Use Command Palette (F1) as alternative

Summary {#verdict}

What you built:

  • VS Code accessible from any browser via HTTPS
  • Password-protected, SSL-encrypted access
  • Full terminal, Git, and extension support
  • Persistent environment — processes continue running when browser is closed
  • Works from any device including tablets and mobile browsers

The setup takes about 30 minutes. After that, it's a full development environment available from anywhere. Particularly useful for quick fixes while traveling, or for team members who want a consistent environment without local setup requirements.

Frequently Asked Questions {#faq}

Is self-hosted code-server suitable for production use?
Yes — code-server is used in production environments ranging from individual developers to small teams. Pair it with regular Lighthouse snapshots and stay current with updates.

How do I migrate from a cloud-hosted code-server to self-hosted?
Export your data from the cloud service, import it to the self-hosted instance, update DNS or internal service configurations, and verify everything works before switching fully.

How much disk space does code-server need?
Initial installation is minimal. Disk usage grows with usage — artifacts, repositories, and caches accumulate over time. Monitor with df -h and use CBS cloud disk expansion when needed.

How do I set up backups for code-server?
Use Lighthouse snapshots for full-server recovery. Additionally, export code-server's application data directly (usually a backup command or data directory export) for granular restore capability.

Can I run code-server alongside other services on the same server?
Yes, with sufficient RAM. Check the resource requirements and monitor actual usage. Containerized deployments (Docker) provide good isolation between services.

👉 Get started with Tencent Cloud Lighthouse
👉 View current pricing and launch promotions
👉 Explore all active deals and offers