Run rust-analyzer on your homelab for 100x less RAM
🤖 Researched and drafted automatically from the official docs, and reviewed before publishing. Commands are taken from the source projects — but always sanity-check before running anything on your own hardware.
rust-analyzer is a language server that gives you full IDE features for Rust without the bloat of RustRover or VS Code Remote. Run it on your homelab, point your editor at it over the network, and get go-to-definition, refactoring, and integrated diagnostics with rustfmt and clippy. The server is lean enough to fit on a mini PC with 4GB RAM; you’ll see the real win when you stop shipping IDE processes to the cloud.
Install rust-analyzer on your homelab machine
- SSH into your homelab box (Debian/Ubuntu or similar).
- Install Rust if you haven’t already:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
- Install rust-analyzer via rustup:
rustup component add rust-analyzer
This places the binary at ~/.cargo/bin/rust-analyzer. Verify it:
rust-analyzer --version
Expose rust-analyzer over the network
rust-analyzer speaks LSP over stdio by default. To run it as a network service, you need a small wrapper that listens on a TCP port and bridges LSP to the network.
- Create a systemd service file to run rust-analyzer with a TCP wrapper. First, install
netcator use a simple Rust TCP bridge. For simplicity, use socat:
sudo apt-get install -y socat
- Create a systemd service at
/etc/systemd/system/rust-analyzer.service:
[Unit]
Description=rust-analyzer Language Server
After=network.target
[Service]
Type=simple
User=rustdev
ExecStart=/home/rustdev/.cargo/bin/rust-analyzer
Restart=always
RestartSec=5
StandardInput=socket
StandardOutput=socket
StandardError=journal
[Install]
WantedBy=multi-user.target
- Create a socket unit at
/etc/systemd/system/rust-analyzer.socket:
[Unit]
Description=rust-analyzer LSP Socket
Before=rust-analyzer.service
[Socket]
ListenStream=127.0.0.1:9257
Accept=yes
[Install]
WantedBy=sockets.target
- Reload systemd and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable rust-analyzer.socket rust-analyzer.service
sudo systemctl start rust-analyzer.socket
- Check that it’s listening:
sudo ss -tlnp | grep 9257
Configure your editor
You now have rust-analyzer listening on 127.0.0.1:9257. Point your editor at it.
VS Code:
- Install the Rust Analyzer extension from the marketplace.
- Open
.vscode/settings.jsonin your workspace and add:
{
"rust-analyzer.server.path": null,
"rust-analyzer.server.extraEnv": {},
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
}
For remote connection, use the Remote - SSH extension to connect to your homelab machine, and rust-analyzer will work transparently.
Vim / Neovim:
Using coc.nvim or nvim-lspconfig:
require('lspconfig').rust_analyzer.setup({
cmd = { "nc", "127.0.0.1", "9257" },
on_attach = on_attach,
capabilities = capabilities,
})
Or with coc.nvim, add to coc-settings.json:
{
"languageserver": {
"rust": {
"command": "nc",
"args": ["127.0.0.1", "9257"],
"filetypes": ["rust"]
}
}
}
Emacs (eglot):
(add-to-list 'eglot-server-programs
'(rust-mode . ("nc" "127.0.0.1" "9257")))
Monitor and tune performance
- Watch memory and CPU usage while editing:
watch -n 1 'ps aux | grep rust-analyzer'
- rust-analyzer respects the
RA_LOGenvironment variable for debug output. Set it in the systemd service if you need to troubleshoot:
Environment="RA_LOG=debug"
- For large monorepos, rust-analyzer can consume more RAM during initial indexing. Let it finish its first pass—after that, incremental updates are cheap.
Keep it safe: firewall and VPN
Never expose port 9257 to the public internet. LSP is not authenticated and gives arbitrary code execution.
- Restrict the socket to localhost only (already done above with
127.0.0.1). - If you need remote access from outside your LAN, use SSH tunneling:
ssh -L 9257:127.0.0.1:9257 user@homelab.local
Then point your editor to 127.0.0.1:9257 on your local machine.
- Or run rust-analyzer behind a VPN (WireGuard, Tailscale) so only authenticated peers can reach it.
Is it worth it?
Yes, if you’re already running a homelab and tired of VS Code’s Remote SSH eating 2GB per connection. rust-analyzer is a thin, fast LSP server that does one job well. On a used mini PC with an N100 and 8GB RAM, you’ll run rust-analyzer, three editor instances, and a build in the background without breaking a sweat. The setup takes an hour, and you own the whole stack. Just keep it on your LAN or behind a VPN, and you’re golden.
Sources
Gear used in this build
* Affiliate links — I earn a small commission at no cost to you. It's gear I use and would genuinely recommend. See the full disclosure.
Related video
New self-hosted AI & homelab shorts, daily.
Subscribe on YouTubeRelated guides
Control a Dumb AC Unit with ESP32 and ESPHome
Wire an ESP32 to your window AC's remote control pins, then command it over your LAN using ESPHome. No Wi-Fi remote needed, total cost under $35.
Self-host Kubernetes: escape the cloud tax
Run Kubernetes on your own hardware to replace managed cloud services. Deploy and scale containerized apps without paying AWS, Azure, or GCP monthly bills.
Run Claude Code and Codex Locally with OtoDock
Deploy OtoDock on your server to get local code generation without cloud API costs. Self-hosted alternative to Claude Code and GitHub Copilot.