GICT knowledge base
How to Install and Use VS Code (Code Server) on Your VPS
Published
Code-server is Visual Studio Code running on a remote machine, delivered to your browser. The editor itself lives on the server. You connect to it over HTTP and get the full VS Code experience, complete with the terminal, extensions, Git integration, and all the keyboard shortcuts you already know. The difference is that the machine doing the actual work is somewhere in a data center, not on your desk.
The use case that makes this worth doing is simple: you want a real development environment accessible from anywhere, on any device, without installing anything locally. Chromebook? Tablet? Borrowed laptop? Public computer at a library? As long as you have a browser and a connection, you have your IDE. The heavy compilation, the tests, the Docker builds, all of it runs on the server’s resources, not the machine in front of you. If you have used Remote SSH in the desktop version of VS Code, code-server is that same experience but without needing VS Code installed anywhere.
A VPS is the right host for this because it is persistent and always-on. Your code and settings stay exactly where you left them. You do not have to keep a laptop running to keep a process running. When you reconnect, you are back in the same environment, same files, same terminal history, same extensions. It behaves like a proper workstation that happens to live in a data center and never goes to sleep.
Another practical benefit: battery life on the road. If you are working from a laptop, all the heavy lifting happens remotely. Your fan stays quiet, your battery lasts longer, and you still have a full development environment with multiple monitors worth of terminal windows.
What You Need Before You Start
You do not need much to get started. A VPS with 1GB of RAM works for light use. For anything involving larger projects, Docker, or multiple extensions, 2GB is a more comfortable floor. The VPS should be running Ubuntu 20.04 or later. Older releases work but the install script handles Ubuntu best.
You also need a non-root user with sudo access. Running code-server as root is not recommended and the install script will warn you about it. Create a regular user, give it sudo rights, and log in as that user for the rest of the process.
A domain name helps for the SSL setup at the end, but it is optional. You can run code-server on an IP address over plain HTTP for testing and lock it down with a firewall for the time being.
Install Code-Server in One Command
The code-server team ships an install script that handles the entire process. It detects your operating system, picks the right package manager, installs the service, and sets up systemd so it starts on boot. Run this on your VPS as your regular user:
curl -fsSL https://code-server.dev/install.sh | sh
The script will print out what it is about to do and ask for your sudo password if it needs it. Read the output so you know what changed on your system.
Once it finishes, verify the install worked:
code-server --version
You should see a version number come back. If it says command not found, the PATH did not stick. Log out and back in, or run source ~/.bashrc, and try again.
Now enable and start the service:
sudo systemctl enable --now code-server@$USER
The @$USER part tells systemd to run the service as your current user. Check that it is running:
systemctl status code-server@$USER
If you see “active (running)” in the output, you are done with the install step. If it says “failed”, check the logs with journalctl -u code-server@$USER to see what went wrong.
Configure Your Password and Access
Code-server ships with password authentication enabled by default. Before you open the browser, set that password. The configuration file lives at ~/.config/code-server/config.yaml. Open it with nano or any text editor you are comfortable with:
nano ~/.config/code-server/config.yaml
You will see something like this:
bind-addr: 127.0.0.1:8080
auth: password
password: your_password_here
cert: false
Change bind-addr to listen on all interfaces if you want to reach it from outside your network:
bind-addr: 0.0.0.0:8080
Replace the plain text password with something strong. Do not leave it as the default. Save the file and restart the service:
sudo systemctl restart code-server@$USER
Open your browser and go to http://your_vps_ip:8080. You will see a login screen. Enter the password from the config file. You should land directly in the VS Code editor.
Install Extensions and Set Up Your Workspace
The Extensions panel on the left side works exactly like desktop VS Code. Search for anything you need and click Install. The extensions run on the server, not in your browser, so they do not slow down the page. One thing to know: if you install the same extensions you use locally, your settings and keybindings carry over if you have a VS Code settings sync account configured. Otherwise, your extensions start fresh on the server, which is fine because that is the point.
A few extensions worth having from the start:
- Python for Python projects
- Docker for managing containers
- GitLens for browsing repo history
- Remote SSH if you plan to connect to other servers from inside this IDE
Set your default workspace folder by editing the config file. Add a line pointing to a directory you created:
~/.config/code-server/config.yaml
default: >/workspace
Create that directory on the server and restart the service. Code-server will open in that folder every time.
Secure It with Nginx and SSL
Right now your IDE is running over plain HTTP. The password is sent over the wire unencrypted. For a quick test that is fine, but for daily use you want TLS. The password is not the only thing flying over the connection. Every file you open, every command you run in the terminal, every search query in your codebase is visible to anyone watching the traffic between you and the server. On a shared network, at a coffee shop, on any untrusted WiFi, plain HTTP is an open door.
The fix is a reverse proxy with SSL. Nginx listens on the public-facing port 443, terminates the TLS encryption, and forwards the decrypted requests to code-server on the local port. This way your traffic is encrypted from your browser to the server, and code-server still gets plain HTTP on the backend.
Install Nginx:
sudo apt update
sudo apt install nginx -y
Create a site config for code-server:
sudo nano /etc/nginx/sites-available/code-server
Paste this config, replacing your_domain.com with your actual domain:
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
Enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Now get a free SSL certificate from Let’s Encrypt using Certbot:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your_domain.com
Follow the prompts. Certbot verifies your domain and writes the certificate files. When it finishes, you can reach your IDE at https://your_domain.com. The connection is encrypted, the password is protected, and you have a proper URL you can bookmark on any device.
Keep It Running
Systemd already handles restarts if the process crashes or if the server reboots. You do not have to do anything special for that part. A few things still worth doing.
Open port 8080 on the VPS firewall so nobody can reach code-server directly from the outside world. Only Nginx on port 443 should be exposed:
sudo ufw allow 443/tcp
sudo ufw allow 80/tcp
sudo ufw deny 8080/tcp
sudo ufw enable
This way, even if someone finds your server IP directly, they cannot hit the code-server port without going through Nginx and SSL first.
Watch the memory use. VS Code is not lightweight, even in server form. The extensions you install, the number of files you have open in the sidebar, the size of the projects you are browsing all add up. If your VPS starts running low on RAM, the OOM killer will terminate processes unexpectedly and you will lose unsaved work. Run htop or free -m regularly to see what is using memory. If code-server is the culprit, try disabling extensions you do not actively use, or reduce the number of open tabs.
Back up your config. The settings, extensions list, and keybindings live in ~/.config/code-server. If you ever need to rebuild the server or move to a new one, you can copy that directory over and restore your environment in minutes. Treat it like any other important config you would not want to lose.
That is the full setup. Code-server running as a systemd service, behind Nginx with SSL, accessible from any browser. Your dev environment, available from anywhere, on any device, with a full VS Code interface and a persistent filesystem.
Related guides
How to Set Up zram on a Small VPS
Configure zram on Ubuntu with kernel and swap checks. Understand compressed memory limits, monitor real use and avoid unsafe swap-file changes.
LinuxHow to Find Services That Need a Restart After Updates with needrestart
Find services using outdated libraries with needrestart on Ubuntu. Read restart reports, review automatic restart policy and plan maintenance safely.
LinuxHow to Limit a Linux Service’s Memory with systemd
Limit a Linux service with systemd MemoryHigh, MemoryMax and swap controls. Check cgroup support, diagnose pressure and remove only your own policy.
LinuxHow to Protect SSH with CrowdSec on Ubuntu
Protect SSH with CrowdSec on Ubuntu. Connect log detection to firewall enforcement and test temporary blocking without losing administrator access.
