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.
- Key Takeaways
Running VS Code on a cloud server offers a specific kind of flexibility:
The one adjustment: keyboard shortcuts behave slightly differently in a browser (the browser intercepts some shortcuts). After a day or two, you adapt.
| 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 |
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
sudo systemctl enable --now code-server@$USER
sudo systemctl status code-server@$USER
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
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.
sudo apt install -y nginx certbot python3-certbot-nginx
Add an A record in your DNS:
code.yourdomain.com → YOUR_SERVER_IP
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.
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).
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.
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt install -y nodejs
sudo apt install -y python3 python3-pip python3-venv
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:
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
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
code-server works in mobile browsers with some limitations:
On iPad/iPhone:
On Android:
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.
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.
| 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 |
✅ What you built:
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.
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.
👉 Get started with Tencent Cloud Lighthouse
👉 View current pricing and launch promotions
👉 Explore all active deals and offers