This guide walks you through installing and configuring code-server on your own VPS, turning it into a private, browser-based cloud IDE. You’ll be able to access your projects from any device with a web browser, with your code and extensions stored on your server. You’ll need a VPS with at least 1 GB of RAM, a domain name (or a willingness to use an IP address), and basic comfort with the command line.
What You’ll Need
- A VPS running Ubuntu 22.04 or 24.04 (other Linux distros work but commands differ)
- SSH access to the VPS (root or a user with sudo privileges)
- A domain name pointing to your VPS’s IP (recommended for HTTPS)
- Open ports 80 and 443 (for HTTP/HTTPS) and 22 (SSH) in your firewall
Step-by-Step
- Connect to your VPS via SSH:
ssh user@your_server_ip - Update the system:
sudo apt update && sudo apt upgrade -y - Download and install code-server using the official install script:
curl -fsSL https://code-server.dev/install.sh | sh. This installs the latest version and creates a systemd service. - Enable and start the service:
sudo systemctl enable --now code-server@$USER(replace$USERwith your actual username, e.g.,code-server@ubuntu). - Check the service status:
sudo systemctl status code-server@$USER– it should be active and running. - Configure the bind address: edit the config file at
~/.config/code-server/config.yaml. Changebind-addrto0.0.0.0:8080(or keep127.0.0.1if you’ll use a reverse proxy). Set a strong password in thepasswordfield. Save and restart:sudo systemctl restart code-server@$USER. - Set up a reverse proxy with Nginx (recommended for HTTPS and a clean URL). Install Nginx:
sudo apt install nginx -y. Create a new site config:sudo nano /etc/nginx/sites-available/code-server. Add a server block that proxies requests tohttp://localhost:8080. Include WebSocket headers (Upgrade and Connection). Example config below. - Enable the site and test:
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/, thensudo nginx -tandsudo systemctl reload nginx. - Obtain an SSL certificate with Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx -y, thensudo certbot --nginx -d yourdomain.com. Follow the prompts to get a free certificate and auto-renewal. - Access your IDE: open
https://yourdomain.comin a browser, accept the self-signed warning if you skipped HTTPS, and log in with the password you set.
Example Nginx config (replace yourdomain.com):
server {
listen 80;
server_name 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;
}
}
Common Mistakes
- Forgetting to open the firewall port – if you can’t connect, check that port 8080 (or 80/443) is allowed in your VPS’s firewall (ufw or cloud provider security group).
- Not enabling the systemd service – code-server won’t start on boot unless you run
systemctl enable. - Using the wrong user in the service name – the service is tied to the user you run it as. If you install as root but start with
@ubuntu, it fails. - Missing WebSocket headers in Nginx – the terminal and some extensions break without the Upgrade/Connection headers.
- Leaving the default password – always change it in the config file.
Tips
- Use a subdomain like
ide.yourdomain.comto keep things tidy. - Set up a swap file if your VPS has less than 2 GB RAM to avoid out-of-memory crashes.
- Back up your
~/.local/share/code-serverdirectory regularly – it contains your extensions and settings. - Enable auto-updates by running the install script periodically, or set up a cron job.
- For better security, consider adding basic auth in Nginx in addition to code-server’s password.
Troubleshooting
- Can’t connect to the web interface – Check if code-server is listening:
ss -tlnp | grep 8080. If not, check the service logs:journalctl -u code-server@$USER -f. - 502 Bad Gateway from Nginx – Usually means Nginx can’t reach code-server. Verify it’s running on 8080 and the proxy_pass URL matches.
- Terminal not working in the browser – Ensure the Upgrade and Connection headers are set in the Nginx config, and that you reloaded Nginx.
- SSL certificate fails – Make sure your domain resolves to the VPS IP before running certbot. Also check that port 80 is open.
- Code-server starts but stops immediately – Check the logs for permission errors. The service runs as your user, so the config file must be readable by that user.
- Slow performance – Close unused extensions, increase VPS RAM, or enable gzip in Nginx for static assets.
Frequently Asked Questions
Can I use code-server without a domain name?
Yes, you can access it via http://your_server_ip:8080, but you’ll get a self-signed certificate warning if you try HTTPS. For personal use, that’s fine, but for security, a domain is recommended.
How do I update code-server?
Re-run the install script: curl -fsSL https://code-server.dev/install.sh | sh. It will replace the binary and keep your config. Then restart the service.
Can I run multiple users on one VPS?
Yes, you can run a separate instance per user, each on a different port, but that requires more RAM. Alternatively, use code-server’s multi-user mode with a reverse proxy and authentication, but it’s more complex.
Is it safe to expose code-server to the internet?
With a strong password and HTTPS, it’s reasonably safe for personal use. For production, consider adding fail2ban, using a VPN, or restricting access by IP.
What if I don’t want to use Nginx?
You can run code-server directly on port 443 with SSL, but that requires manual certificate management. Nginx simplifies HTTPS and adds a layer of security.
Can I access my local files from the cloud IDE?
Code-server runs on the VPS, so it only sees files on the VPS. You can sync files using git, or mount a remote drive, but it’s not a direct bridge to your local machine.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- OLED TVs in Dark Rooms: Why They Look Better and When They Don’t
- Philips DST7060/20 7000 Series Iron: Specs & Fit
- Coal Fueled Jet Aircraft: Could It Work?675 L
- Remote Desktop on Raspberry Pi: How to Enable It
- Word Select Last Line in Paragraph?
- Google Assistant IFTTT Recipes: 7 Useful Automations