Deploy the mihomo core on Linux: Install a desktop client and run it from the command line with systemd
Two ways to deploy mihomo on Linux: install a GUI client on a desktop, or run mihomo as a systemd service on a server or headless system.
Choose a setup: GUI client or standalone core
If you want to switch subscriptions, nodes, and rule modes from your desktop, install a GUI client. Choose one that supports mihomo, and check whether its installer includes the core. If mihomo needs to keep running after you disconnect from SSH or restart a server, run the standalone core under systemd. The two setups can be used independently—there’s no need to install a desktop environment just to run a server service.
uname -m
cat /etc/os-release
ps -p 1 -o comm=
systemctl --version
x86_64corresponds toamd64in most releases, whileaarch64usually corresponds toarm64. If releases for the same architecture offer different instruction set builds, follow the release notes. For older processors, don’t rely on the architecture name alone.- For Debian-based distributions such as Ubuntu 24.04, start with the DEB package; for Fedora, choose RPM. If there’s no package for your distribution, check whether the client offers an AppImage for your architecture.
- The command-line setup requires systemd as PID 1. The service below uses
StateDirectory=, introduced in systemd 235. Havingsystemctlinstalled in a container doesn’t mean this service can run there.
Desktop setup: import a profile and connect your browser
- Install the client. Open the Linux client section from the download page. Install a DEB or RPM with your distribution’s package installer, or run
sudo apt installorsudo dnf installin a terminal. Drag the local package into the command line, then run the command using an absolute path or a relative path starting with./. - Import and select a profile. For example, in Clash Verge Rev, open Subscriptions in the sidebar and add a subscription URL or import a local YAML file. Then select the profile card. Importing only adds the profile to the list. After switching, open Proxies and confirm the policy groups defined by that profile appear. Choose nodes for any groups that require manual selection.
- Check the proxy port. In the client’s Settings, find the actual mixed port it listens on. The examples below use
7890; this isn’t necessarily the client’s default. First test the port explicitly from a terminal, then enable System Proxy in the client. On the Ubuntu 24.04 GNOME desktop, for example, check the proxy status under Settings → Network → Network Proxy.
AppImages generally aren’t installed through a package manager. In GNOME Files, for example, right-click the file, open Properties → Permissions, and allow it to run as a program. Then launch it. If the terminal reports that FUSE is missing, install the required runtime library according to your distribution and the AppImage’s instructions, or use your distribution’s native package instead.
Command-line setup: install the binary and create a minimal config
Download the Linux mihomo core for your architecture, extract it, and name the binary mihomo. From the directory containing the file, install it at a fixed path. Check the version output on this machine; use that version when troubleshooting config compatibility, not the version number of a desktop client.
sudo install -m 0755 ./mihomo /usr/local/bin/mihomo
/usr/local/bin/mihomo -v
command -v nologin
sudo useradd --system --user-group --no-create-home --shell "$(command -v nologin)" mihomo
sudo install -d -o root -g mihomo -m 0750 /etc/mihomo
sudoedit /etc/mihomo/config.yaml
sudo chown root:mihomo /etc/mihomo/config.yaml
sudo chmod 0640 /etc/mihomo/config.yaml
First, confirm that command -v nologin returns the path to an executable, then create the account. Run useradd only for a first-time setup when no dedicated account or group with that name exists. An administrator should manage the config, which the service account only needs to read. Put caches and any generated rule resources in a separate writable directory. Keep subscription URLs and node credentials in restricted files, not in public logs or screenshots.
Save the YAML below as /etc/mihomo/config.yaml. This config tests the local HTTP/SOCKS proxy and direct connections. It doesn’t use any nodes or change the host’s default route.
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
tun:
enable: false
rules:
- MATCH,DIRECT
The mixed port accepts both HTTP proxy and SOCKS requests. allow-lan: false restricts access to the local machine, so you don’t need to add an inbound firewall rule. MATCH,DIRECT sends every request through this port directly to its destination. A subscription URL saved in a GUI client isn’t the same as a core config file. When switching to a real config, get a complete YAML file compatible with mihomo, then check its policy groups, rules, and listener settings.
Run mihomo under systemd with a dedicated account
Create the service with sudoedit /etc/systemd/system/mihomo.service. -d sets the core’s working data directory, and -f specifies the config file; they don’t have to be in the same directory. systemd creates /var/lib/mihomo and assigns it to the service account. If your production config references external files, make sure the account can read them.
[Unit]
Description=mihomo local proxy
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=mihomo
Group=mihomo
StateDirectory=mihomo
StateDirectoryMode=0750
ExecStartPre=/usr/local/bin/mihomo -t -d /var/lib/mihomo -f /etc/mihomo/config.yaml
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
ExecStartPre tests the config as the service account before startup; if the test fails, the service won’t start. This unit is for a standard local proxy. TUN requires network interface and routing permissions—you can’t enable it just by changing enable to true in the YAML. network-online.target controls startup order; it doesn’t guarantee that subscription URLs or rule sources are reachable.
sudo systemctl daemon-reload
sudo systemctl start mihomo.service
systemctl status mihomo.service --no-pager
sudo journalctl -u mihomo.service -n 50 --no-pager
After confirming the service starts and completing the request test in the next section, run sudo systemctl enable mihomo.service to start it at boot. After changing only the YAML, restart the service. If you edit the unit file, run sudo systemctl daemon-reload before restarting. Keep a working copy before replacing the config with your production version. If startup or forwarding fails, restore the copy and restart the service.
Verify the connection: check the listener, then test forwarding
sudo ss -ltnp 'sport = :7890'
curl -q --noproxy '' --proxy http://127.0.0.1:7890 --max-time 10 -I https://example.com/
curl -q --noproxy '' --proxy socks5h://127.0.0.1:7890 --max-time 10 -I https://example.com/
sudo journalctl -u mihomo.service -n 50 --no-pager
Use ss to see which process is listening on TCP port 7890. The two curl commands test the HTTP and SOCKS endpoints, with a 10-second timeout. socks5h lets the proxy resolve the destination hostname. An HTTP proxy test may first return 200 Connection established; that only confirms the CONNECT tunnel was established, so check the response from the destination site too. With the minimal config, a successful response confirms that the local proxy and direct connection work—it doesn’t mean traffic is going through a remote node.
| Symptom | What to check first |
|---|---|
Exec format error | Check the binary’s architecture and make sure you installed the extracted file, not the archive. |
address already in use | Use ss to find which process owns the port. A desktop client and standalone core on the same machine may both be configured to use 7890. Stop one of them, or change the port and update the apps that connect to it. |
Config read error: permission denied | Check that the service account can access /etc/mihomo and read the YAML. If the error points to a cache or rule file, check read and write permissions on the relevant path. |
| Service is running, but proxy requests time out | First, test the host’s direct connection with curl -q --noproxy '*' --max-time 10 -I https://example.com/. If timeouts start only after switching to your production config, check the logs for the matching rule, policy group, and node. |
After testing, configure only the apps that need a proxy to use this local port. There’s no need to set HTTP_PROXY globally or change the server’s system routes. To stop the service entirely, run sudo systemctl disable --now mihomo.service, then remove any app settings that point to the port.