Run on a server
Use this page to run the daemon on a machine that stays on and log in to WeChat there. Pick one way. Each one owns the daemon process, so don’t combine them.
| Way | Choose it when |
|---|---|
| Docker Compose | You want the daemon and its data kept apart from the rest of the host. Recommended. |
wx daemon | You want a quick background run on any OS. |
| systemd user service | You run wx directly on Linux and want it to restart on failure. |
Docker Compose
The image is ghcr.io/thisnick/agent-wechat-native (linux/amd64 and linux/arm64). It runs as user 10001 with a read-only filesystem and keeps its data in Docker volumes. Start from the example compose.yaml and server.toml.
-
Put both files in a folder. In
compose.yaml, setimage:toghcr.io/thisnick/agent-wechat-native:latestand delete thebuild:section. -
Create an API token: one copy for your CLI, one owned by the container user.
Terminal window umask 077; mkdir -p ~/.config/agent-wechat secretshead -c 32 /dev/urandom | base64 > ~/.config/agent-wechat/box-tokensudo install -m 600 -o 10001 -g 10001 ~/.config/agent-wechat/box-token secrets/api-token -
Start the container.
Terminal window docker compose up -d -
Create an account and log in inside the container. The token is mounted at
/run/secrets/wechat-api-token. Scan the QR code as described in Connect your account.Terminal window docker compose exec agent-wechat-native wx --token-file /run/secrets/wechat-api-token accounts create --alias medocker compose exec agent-wechat-native wx --token-file /run/secrets/wechat-api-token auth login -
To use the daemon from the host, save it as a server. The daemon listens on
127.0.0.1:6174of the host.Terminal window wx config servers add box --url http://127.0.0.1:6174 \--token-file ~/.config/agent-wechat/box-tokenwx --server-name box accounts get
To use existing WeChat for Linux data, add its folder (the one that contains xwechat_files and .xwechat) under volumes: as /home/you:/profiles/wechat, then log in with --official=/profiles/wechat. The container user needs write access to that folder, and the WeChat app must be stopped.
On macOS and Windows, Docker Desktop runs the same image. The example uses host networking, so turn it on under Settings › Resources › Network.
wx daemon
wx daemon starts wx serve in the background for the current user. It works on any OS but does not restart after a failure or reboot.
wx daemon startwx daemon statuswx daemon restartwx daemon logs --followwx daemon stopThen follow Connect your account to log in.
systemd
On Linux, a systemd user service restarts the daemon on failure and starts it with your user session. It needs wx installed (Install). Stop any running daemon first (wx daemon stop, or quit the desktop app).
-
Preview the unit file without installing it.
Terminal window wx daemon install --dry-run -
Install and start the service. It asks before writing the unit or calling
systemctl; add--yesto skip the question.Terminal window wx daemon installThis writes
~/.config/systemd/user/agent-wechat-native.servicefrom the shipped user unit, with the path towx, your data folder and server config, and write access to the folders of any--officialprofiles you have registered. -
On a headless server, let the service run without a login session.
Terminal window loginctl enable-linger -
Log in as in Connect your account. Manage the service later with:
Terminal window wx daemon statuswx daemon restartwx daemon uninstall # removes the service unit; keeps your data
If you add an --official profile after installing, run wx daemon uninstall and wx daemon install again so the unit can write to WeChat’s folders.
Next steps
- The daemon listens on
127.0.0.1:6174only. To reach it from other machines, see Reach it from other machines. - Data lives in the daemon’s data folder and in the WeChat profile. For what to back up, see Back up and maintain.