homelabprivacyai

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

  1. SSH into your homelab box (Debian/Ubuntu or similar).
  2. Install Rust if you haven’t already:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
  1. 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.

  1. Create a systemd service file to run rust-analyzer with a TCP wrapper. First, install netcat or use a simple Rust TCP bridge. For simplicity, use socat:
sudo apt-get install -y socat
  1. 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
  1. 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
  1. 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
  1. 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:

  1. Install the Rust Analyzer extension from the marketplace.
  2. Open .vscode/settings.json in 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

  1. Watch memory and CPU usage while editing:
watch -n 1 'ps aux | grep rust-analyzer'
  1. rust-analyzer respects the RA_LOG environment variable for debug output. Set it in the systemd service if you need to troubleshoot:
Environment="RA_LOG=debug"
  1. 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.

  1. Restrict the socket to localhost only (already done above with 127.0.0.1).
  2. 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.

  1. 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.

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 YouTube

Related guides

← All guides