· Platforms · 9 min read

Deploy mihomo on Linux: CLI, systemd service, and web dashboard

Set up mihomo on Linux desktops or headless servers, covering binary paths, config directories, systemd startup, and web dashboard access.

Choose the right Linux binary and keep config and data separate

Run uname -m first. An x86_64 result corresponds to the release package's amd64 build, while aarch64 corresponds to arm64. If an older x86 machine reports Illegal instruction, check the CPU instruction set required by the build and choose a compatible build from the release page. The steps below assume you have extracted the download and renamed the binary in the current directory to mihomo.

Terminal · Install the core and check its version
sudo install -m 0755 ./mihomo /usr/local/bin/mihomo
/usr/local/bin/mihomo -v

Run -v with the absolute path to verify that the newly installed binary works and avoid accidentally checking another program with the same name elsewhere on the system. Next, run the core under a dedicated account: an administrator maintains the program, the service account gets read-only access to the main config, and indexes, caches, and runtime downloads go in a separate directory. These paths work for both desktops and servers.

Terminal · Create the service account and directories (first-time setup)
sudo useradd --system --user-group --home-dir /var/lib/mihomo \
  --no-create-home --shell /usr/sbin/nologin mihomo
sudo install -d -o root -g mihomo -m 0750 /etc/mihomo
sudo install -d -o mihomo -g mihomo -m 0750 /var/lib/mihomo

These commands assume the system has useradd and that nologin is at /usr/sbin/nologin; on other distributions, verify its location with command -v nologin first. If mihomo is already deployed, use id mihomo to check the existing user and group, then confirm which service uses the old directories before deciding whether to reuse them. Don't create a duplicate account or overwrite a config that's in use.

Run a minimal config in the foreground to verify the proxy port

For the first run, leave subscriptions, rule sets, DNS, and TUN for later. Save the content below as config.yaml in the current directory. mixed-port accepts both HTTP proxy and SOCKS requests on the same port; MATCH,DIRECT sends all requests directly from this Linux host. This config only checks that the proxy listener works; it includes no remote nodes.

config.yaml · Test local connectivity
mixed-port: 7890
bind-address: '127.0.0.1'
allow-lan: false
mode: rule
log-level: info
rules:
  - MATCH,DIRECT
Terminal · Install, validate, and run the config in the foreground
sudo install -o root -g mihomo -m 0640 config.yaml /etc/mihomo/config.yaml
sudo -u mihomo /usr/local/bin/mihomo -t -d /var/lib/mihomo -f /etc/mihomo/config.yaml
sudo -u mihomo /usr/local/bin/mihomo -d /var/lib/mihomo -f /etc/mihomo/config.yaml

-f specifies the main config file, and -d specifies the core's data directory. Use the same values when validating, running in the foreground, and starting the service; otherwise, the CLI and service may load different configs. Start the process only after -t passes. A successful config check does not replace testing the listener and network connectivity.

Leave the foreground process running and open another terminal. First check whether 7890 is listening, then explicitly set the HTTP proxy. This clears curl's proxy bypass list so the current terminal's NO_PROXY setting can't send the test request directly.

Second terminal · Check the listener and make a real request
sudo ss -ltnp 'sport = :7890'
curl --noproxy '' --proxy http://127.0.0.1:7890 \
  --connect-timeout 5 --max-time 15 -I https://example.com

The listener should be bound to the loopback address and belong to the mihomo process. If the port is listening but there's no HTTP response, check the foreground logs, then compare the result with a direct request to the same site from this machine. A response confirms only that the proxy listener and direct connection work. After switching to your own Clash-format YAML, also check that the rules match the intended policy group and that the group has a node selected. A subscription URL or Base64-encoded node list cannot be used as the main config as-is.

Run mihomo as a systemd service and enable startup at boot

Go back to the foreground terminal and press Ctrl + C. Use ss to confirm the port has been released before switching to the service; otherwise, the two processes will compete for 7890. Run ps -p 1 -o comm= to confirm that systemd manages the system. If systemd isn't running in your container, keep using the foreground command and let the container's process manager handle it.

Use sudoedit /etc/systemd/system/mihomo.service to add the unit below. StateDirectory maps to /var/lib/mihomo, which systemd manages at startup. Failed restarts are spaced 5 seconds apart. network-online.target only provides a network-ready startup ordering target; it does not guarantee that subscription URLs or remote rule sources are reachable.

/etc/systemd/system/mihomo.service
[Unit]
Description=mihomo proxy core
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=mihomo
Group=mihomo
StateDirectory=mihomo
StateDirectoryMode=0750
WorkingDirectory=/var/lib/mihomo
ExecStart=/usr/local/bin/mihomo -d /var/lib/mihomo -f /etc/mihomo/config.yaml
Restart=on-failure
RestartSec=5s
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
Terminal · Reload the unit, start the service, and check its status
sudo systemctl daemon-reload
sudo systemctl enable --now mihomo.service
systemctl is-enabled mihomo.service
systemctl status mihomo.service --no-pager
sudo journalctl -u mihomo.service -b -n 60 --no-pager

enabled means the service is set to start at boot; active (running) means the process is currently running. Once both are confirmed, repeat the proxy request from the previous section. When changing only the YAML, run the same -t command as the service account, then run sudo systemctl restart mihomo.service. Run daemon-reload only after changing the .service file. Before replacing a config, keep a backup with equally restrictive permissions so you can recover if new rules or a subscription cause problems.

Connect a web dashboard and keep the controller port on loopback

7890 is the proxy listener; the web dashboard uses a separate controller API. This example uses 9090, bound only to 127.0.0.1. The dashboard can show connections, read runtime information, and switch policies. Treat the controller secret as an administrative credential; never reuse a subscription link or account password.

  1. Get prebuilt dashboard files that are compatible with your mihomo version. Place them in /var/lib/mihomo/ui/ and confirm the entry point is /var/lib/mihomo/ui/index.html, not nested inside an extra directory from the archive. The service account must be able to traverse the directories and read the files.
  2. Use sudoedit /etc/mihomo/config.yaml to add the two top-level fields below. Generate a random key with openssl rand -hex 32, add it as a secret field at the same level, and save the generated value as a quoted string. Check that the config contains no duplicate keys with the same name.
  3. Validate the config as the service account, then restart the service. Run sudo ss -ltnp 'sport = :9090' to confirm that it listens only on loopback. On the desktop, open http://127.0.0.1:9090/ui/ and enter the controller address http://127.0.0.1:9090 and the secret you just set in the dashboard's connection settings. The controller address does not include /ui/.
config.yaml · Controller and dashboard directory
external-controller: '127.0.0.1:9090'
external-ui: ui

Headless server · Access the dashboard from your local browser

Set up SSH local port forwarding on your own computer; there's no need to open 9090 on the server. mihomo-server below is an SSH host alias already configured on your computer. If you don't have that alias, replace it with the destination you normally use to connect to the server. 19090 is the local port on your computer; 9090 is the port on the server.

ssh -N -o ExitOnForwardFailure=yes \
  -L 127.0.0.1:19090:127.0.0.1:9090 mihomo-server

Keep the SSH session open, then visit http://127.0.0.1:19090/ui/ on your computer. Set the dashboard's controller address to http://127.0.0.1:19090 and keep using the secret configured on the server. Don't bind the controller to a public IP to solve access issues. When the SSH session closes, the local forwarding endpoint disappears, but mihomo continues running on the server.

Troubleshoot startup failures, port conflicts, and dashboard errors

Troubleshoot in this order: process, listener, request. If the process won't start, check the service logs first. A working proxy port doesn't mean the controller is working too; check each port separately.

Symptom What to check first
Service reports 203/EXEC Check the ExecStart path, file execute permissions, and binary architecture. Run -v using the unit's absolute path to confirm the file isn't still a compressed archive.
Logs show permission denied Check which file the error points to. The main config must be readable, parent directories must be traversable, and the data directory must be writable. Rerun the check as the service account; a successful test as root does not confirm that permissions are correct.
Logs show address already in use Use ss to check 7890 and 9090 separately. Identify whether the process holding each port is an old core instance, a desktop client, or another service, then stop the duplicate process or change the relevant port.
/ui/ returns 404 First confirm the request is going to the controller port, then check the directory resolved from external-ui and -d together. Make sure the dashboard entry point and static assets are in that directory.
Dashboard loads, but API requests return 401 Check the controller address and secret saved in the dashboard. If you changed secret, restart the service to apply the file change and update the connection settings in your browser.

If repeated config errors trigger systemd's start rate limit, fix the config and pass validation first. Then run sudo systemctl reset-failed mihomo.service and sudo systemctl start mihomo.service. Once the base service is stable, add subscriptions, rule sets, and DNS one at a time. Changing only one category of settings at a time makes it easier to pinpoint the cause if something breaks.

Download Clash