Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Set Up a Web-Based Code Server on Linux

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. Update your system
    Run sudo apt update && sudo apt upgrade -y to refresh package lists and upgrade existing packages.
  2. 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.
  3. 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 the arm64.deb file instead.
  4. Install the .deb package
    Run sudo dpkg -i code-server_4.96.2_amd64.deb. If you get dependency errors, run sudo apt install -f to fix them.
  5. Start code-server manually (first test)
    Run code-server in your terminal. It will start on localhost:8080 and print a password. Open http://localhost:8080 in a browser on the same machine to verify it works. Press Ctrl+C to stop it.
  6. 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 (replace yourusername with 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 with Ctrl+O, exit with Ctrl+X.
  7. Enable and start the service
    Run sudo systemctl enable code-server then sudo systemctl start code-server. Check status with sudo systemctl status code-server – it should say “active (running)”.
  8. 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 the password: line to a strong password of your choice. Save and restart: sudo systemctl restart code-server.
  9. 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.
  10. Access from another device
    From any browser, go to http://YOUR_SERVER_IP:8080. Enter the password you set. You should see the VS Code interface.
  11. 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
    }

    Replace code.example.com with 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.yaml require 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@server then open http://localhost:8080 locally.
  • 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-server directory – it contains settings and installed extensions.
  • Use --auth none only 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.