Set Up a Web-Based Code Server on Linux
In this article
Yes, you can run a full VS Code experience in your browser on a Linux server using code-server. It lets you edit files, run terminals, and install extensions from any device with a browser. First, you need a Linux machine (Ubuntu/Debian shown here) with sudo access, a non-root user, and port 8080 open if you plan to access it remotely.
What You'll Need
- A Linux server (Ubuntu 20.04+ or Debian 10+ recommended) with sudo privileges.
- At least 1 GB RAM and 2 GB free disk space.
- An open port (default 8080) in your firewall/router if accessing remotely.
- A domain name or IP address for remote access (optional but recommended).
- Basic comfort with the command line.
Step-by-Step
- Update your system
Runsudo apt update && sudo apt upgrade -yto refresh package lists and upgrade existing packages. - Install dependencies
Install curl, wget, and tar if not already present:sudo apt install -y curl wget tar. These are needed to download and extract code-server. - Download code-server
Visit the official GitHub releases page (github.com/coder/code-server/releases) to find the latest Linux binary. For most x86_64 systems, run:curl -fOL https://github.com/coder/code-server/releases/download/v4.96.2/code-server_4.96.2_amd64.deb
Replace the version number with the latest one from the releases page. If you have an ARM system (like a Raspberry Pi), download thearm64.debfile instead. - Install the .deb package
Runsudo dpkg -i code-server_4.96.2_amd64.deb. If you get dependency errors, runsudo apt install -fto fix them. - Start code-server manually (first test)
Runcode-serverin your terminal. It will start onlocalhost:8080and print a password. Openhttp://localhost:8080in a browser on the same machine to verify it works. PressCtrl+Cto stop it. - Create a systemd service (so it runs in the background)
Create a service file:sudo nano /etc/systemd/system/code-server.service. Paste the following (replaceyourusernamewith your actual Linux username):[Unit] Description=code-server After=network.target [Service] Type=simple User=yourusername ExecStart=/usr/bin/code-server --bind-addr 0.0.0.0:8080 --auth password Restart=always [Install] WantedBy=multi-user.target
Save withCtrl+O, exit withCtrl+X. - Enable and start the service
Runsudo systemctl enable code-serverthensudo systemctl start code-server. Check status withsudo systemctl status code-server– it should say “active (running)”. - Set your password
Code-server uses a password stored in~/.config/code-server/config.yaml. Edit that file:nano ~/.config/code-server/config.yaml. Change thepassword:line to a strong password of your choice. Save and restart:sudo systemctl restart code-server. - Open the firewall (if needed)
If you have UFW enabled, allow port 8080:sudo ufw allow 8080/tcp. If you use a cloud provider (AWS, DigitalOcean, etc.), also open port 8080 in their security group/firewall settings. - Access from another device
From any browser, go tohttp://YOUR_SERVER_IP:8080. Enter the password you set. You should see the VS Code interface. - Secure with HTTPS (recommended for internet use)
For production use, install a reverse proxy like Caddy or Nginx with Let’s Encrypt. Example with Caddy: install Caddy, then add this to/etc/caddy/Caddyfile:code.example.com { reverse_proxy localhost:8080 }
Replacecode.example.comwith your domain, ensure DNS points to your server, then restart Caddy. It will auto-obtain an SSL certificate.
Common Mistakes
- Running as root – code-server refuses to run as root by default. Always use a non-root user.
- Wrong architecture – Downloading the amd64 .deb on an ARM machine (like Raspberry Pi) will fail. Check with
uname -m. - Forgetting to open the firewall – The service runs, but you can’t connect from outside. Check both UFW and cloud security groups.
- Editing config while service is running – Changes to
config.yamlrequire a restart to take effect. - Using a weak password – The default password is random but insecure if left. Always change it.
Tips
- Use SSH port forwarding for a quick secure test:
ssh -L 8080:localhost:8080 user@serverthen openhttp://localhost:8080locally. - Install extensions from the VS Code marketplace inside code-server – it works the same as desktop VS Code.
- Set up a domain and HTTPS early – it avoids browser warnings and secures your code.
- Back up your
~/.config/code-serverdirectory – it contains settings and installed extensions. - Use
--auth noneonly on a trusted local network; never expose that to the internet.
Troubleshooting
If the service fails to start: Check logs with sudo journalctl -u code-server -n 50. Common issues: missing user in the service file, or the port is already in use (change --bind-addr to another port).
If you can’t connect from another device: First test locally on the server with curl http://localhost:8080. If that works, check sudo ufw status and your cloud provider’s firewall. Also verify the service is listening on 0.0.0.0, not just 127.0.0.1.
If the page loads but shows “Connection refused”: The service may have crashed. Restart with sudo systemctl restart code-server and check logs.
If you forgot the password: Edit ~/.config/code-server/config.yaml, change the password, and restart the service.
If you get a “permission denied” error when opening files: Make sure the user running code-server has read/write permissions on the directories you’re editing. Use chown -R yourusername:yourusername /path/to/project.
Frequently Asked Questions
Can I use code-server on a Raspberry Pi?
Yes. Download the arm64.deb package from the releases page. Performance will be slower on older models, but it works.
Is code-server free?
Yes, it’s open-source (MIT license) and free to use, including for commercial purposes.
Can I install VS Code extensions?
Yes. Open the Extensions view in code-server and search/install from the Open VSX Registry. Some extensions from the Microsoft Marketplace may not be available, but most popular ones are.
How do I update code-server?
Download the new .deb package from the releases page and run sudo dpkg -i again. The service will keep your config and extensions.
Can I run multiple code-server instances for different users?
Yes. Create separate systemd services with different ports and different users, each with their own config directory. Ensure each user has a separate home directory.
Is it safe to expose code-server directly to the internet?
Not recommended. Use a reverse proxy with HTTPS and strong authentication. Also consider adding fail2ban to block brute-force attempts.