Skip to main content

Command Palette

Search for a command to run...

Self-Hosting code-server at Home for Remote Development

Published
3 min read

After working remotely for a while with different setups, I decided to build my own development environment at home using code-server. The reason is simple: I already have a home server running Ubuntu that hosts multiple services (Nginx, Docker, Portainer, etc.), and I wanted a private, self-hosted coding environment without relying on third-party platforms like code.dev or GitHub Codespaces.

This post covers how I set up code-server, how I used Cloudflare as a proxy, and how I solved two issues I ran into (WebSocket errors + GitHub Copilot installation failure).


🧩 Why choose code-server?

  • Run VS Code in the browser from anywhere.

  • Full privacy --- no source code uploaded to external services.

  • Works perfectly on a home server that runs 24/7.

  • Lightweight, easy to deploy, Linux-friendly.

Self-hosting gives you complete control: no time limits, no subscription lock-ins, and total data privacy.


1. Using Cloudflare as DNS Manager & Proxy to Hide Your IP

I use Cloudflare for DNS and enable Proxy Mode (orange cloud) to hide my home server's real IP. The connection flow becomes:

Client → Cloudflare (Proxy) → Nginx (home server) → code-server

Benefits:

  • Real IP is fully hidden behind Cloudflare.

  • Free HTTPS certificates.

  • Extra protection via firewall rules or Cloudflare Access.

On the server side, Nginx acts as a reverse proxy and forwards traffic to code-server running locally (typically on port 8080).


2. Issues Encountered During Setup

Here are the two issues I faced and how I fixed them.


❗ Issue 1: code-server WebSocket Errors When Using Nginx

Symptoms

  • code-server loads, but the UI is incomplete or broken.

  • Browser console errors like WebSocket connection failed.

  • Extensions fail to load.

Cause

code-server relies heavily on WebSockets for internal communication.
However, Nginx does not forward WebSocket headers by default.
When traffic flows through Cloudflare → Nginx, the WebSocket connection is downgraded to plain HTTP, causing failures.

Fix

Add these required WebSocket headers inside your Nginx location block:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;

After updating the configuration and reloading Nginx, WebSockets work without issues.


❗ Issue 2: GitHub Copilot Cannot Be Installed in code-server

Symptoms

When installing Copilot:

  • Failed to install extension...\

  • Download fails from the extension gallery.

Cause

code-server does NOT use the official VS Code Marketplace due to licensing issues.
Instead, it uses Open VSX Registry, and GitHub Copilot is not published there.

→ Therefore, code-server cannot find or install the extension.

Fix

You must "override" the default marketplace by adding a system environment variable inside the code-server systemd service.

  1. Open the service file:
sudo nano /etc/systemd/system/code-server.service
  1. Add this under the [Service] section:
Environment=EXTENSIONS_GALLERY='{"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery", "itemUrl": "https://marketplace.visualstudio.com/items"}'
  1. Reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart code-server

Now Copilot installs normally.

Note

  • This is unofficial, but widely used in self-hosted setups.

  • Occasionally the Microsoft Marketplace rate-limits requests, but generally everything works well.


🎉 Conclusion

Self-hosting code-server at home gives tremendous flexibility and control, especially if you already have a 24/7 home server. Combining Cloudflare and Nginx provides extra security and keeps your IP private.

Even though you may encounter issues like WebSocket errors or problems installing GitHub Copilot, both can be solved easily with small configuration tweaks.

If you want a private, fast, remote development environment, code-server is absolutely worth trying!