#3255·mihomo

WireGuard outbound: config reload (PUT /configs) leaves the old device running — two sockets with one key, the peer's endpoint flaps

Author: shidohCreated Sep 27, 2026Updated Sep 27, 2026

Verify steps

  • I have read the documentation and understand the meaning of all the configuration items I have written.
  • I have carefully reviewed the documentation and have not resolved the issue.
  • I have searched the Issue Tracker for the issue I want to raise and did not find it.
  • I am a non-Chinese user.
  • I have tested with the latest Alpha branch version, and the issue still persists.
  • I have provided the server and client configuration files and processes that can reproduce the issue locally.
  • I provided the simplest configuration that can be used to reproduce the errors in my report.
  • I have provided complete logs.
  • I have directly reproduced the error using the Mihomo command-line program.

Operating System

MacOS

System Version

macOS 26.7 (arm64)

Mihomo Version

Mihomo Meta alpha-63bd52e darwin arm64 with go1.26.8 Sun Sep 27 01:30:49 UTC 2026
Use tags: with_gvisor

Configuration File

Client (/tmp/wgrepro/wg/config.yaml; test-only keys generated for this repro):

yaml
mixed-port: 17892
external-controller: 127.0.0.1:19092
log-level: debug
ipv6: false
proxies:
  - name: wg
    type: wireguard
    server: 192.168.105.5        # local Linux VM, plain kernel WireGuard
    port: 51820
    ip: 10.9.0.2
    private-key: <client private key>
    public-key: <server public key>
    udp: true
    persistent-keepalive: 5
rules:
  - MATCH,wg

Server (Ubuntu 24.04 VM, kernel 6.8, wg-quick up wgr0; python3 -m http.server 8080 --bind 10.9.0.1 as the target):

ini
[Interface]
Address = 10.9.0.1/24
ListenPort = 51820
PrivateKey = <server private key>

[Peer]
PublicKey = <client public key>
AllowedIPs = 10.9.0.2/32

Description

After a config reload through the API, the WireGuard outbound created by the previous config is not closed. The new config brings up a second WireGuard device with the same private key and a new UDP source port, so the client holds two sockets to the same server. A WireGuard server keeps one endpoint per peer key; as both devices send (keepalives here), the peer's endpoint on the server switches between the two source ports. The old socket stays until the core restarts (POST /restart).

The log shows no teardown of the old device at the reload (23:49:17): only a new device coming up.

On the local test path (~1 ms) requests still succeeded, since WireGuard recovers fast there. On a real ~75 ms path the same flapping made roughly every other health check through the proxy time out, and a fallback group moved off the WireGuard proxy.

GUI clients apply a subscription update exactly this way. Clash Verge Rev refreshes subscriptions daily by default, so every refresh leaves a WireGuard proxy half-working until the core is restarted by hand.

Also seen on Linux (mihomo in Docker, an earlier 1.19.x build) with the same symptom after PUT /configs, and with amnezia-wg-option set.

Reproduction Steps

  1. mihomo -d /tmp/wgrepro/wg -f /tmp/wgrepro/wg/config.yaml
  2. curl -x http://127.0.0.1:17892 http://10.9.0.1:8080/ — works.
  3. netstat -anv -p udp | grep 192.168.105.5.51820 — one socket (local port 54844). On the server, wg show wgr0 endpoints — :54844, steady.
  4. curl -X PUT 'http://127.0.0.1:19092/configs?force=true' -d '{"path":"/tmp/wgrepro/wg/config.yaml"}' — the same file, unchanged; 204.
  5. Step 2 again, then step 3 — two sockets: 58487 54844.
  6. On the server, wg show wgr0 endpoints every 2 s: 58487 54844 54844 54844 54844 58487 54844 58487 54844 54844 58487 54844 58487 54844 54844.
  7. Both sockets are still there after another 30 requests (~50 s).
  8. curl -X POST http://127.0.0.1:19092/restart — one socket (51686), server endpoint steady again.

Expected: a reload closes the previous WireGuard device, so only one socket per server remains.

Logs

Complete log, log-level debug (steps 1–8; restart at 23:50:06)
time="2026-09-27T23:48:47.439766000+05:00" level=info msg="Start initial configuration in progress"
time="2026-09-27T23:48:47.439968000+05:00" level=info msg="Geodata Loader mode: memconservative"
time="2026-09-27T23:48:47.439982000+05:00" level=info msg="Geosite Matcher implementation: succinct"
time="2026-09-27T23:48:47.440032000+05:00" level=info msg="Initial configuration complete, total time: 0ms"
time="2026-09-27T23:48:47.440276000+05:00" level=info msg="RESTful API listening at: 127.0.0.1:19092"
time="2026-09-27T23:48:47.441695000+05:00" level=info msg="Sniffer is closed"
time="2026-09-27T23:48:47.441777000+05:00" level=info msg="Mixed(http+socks) proxy listening at: 127.0.0.1:17892"
time="2026-09-27T23:48:47.441807000+05:00" level=info msg="Start initial compatible provider default"
time="2026-09-27T23:48:50.453567000+05:00" level=debug msg="Auth success from 127.0.0.1:52877 -> "
time="2026-09-27T23:48:50.453736000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:50.453764000+05:00" level=debug msg="[WG](wg) UAPI: Updating private key"
time="2026-09-27T23:48:50.453878000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - UAPI: Created"
time="2026-09-27T23:48:50.453888000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - UAPI: Updating endpoint"
time="2026-09-27T23:48:50.453897000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - UAPI: Adding allowedip"
time="2026-09-27T23:48:50.453904000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - UAPI: Updating persistent keepalive interval"
time="2026-09-27T23:48:50.453929000+05:00" level=debug msg="[WG](wg) Interface up requested"
time="2026-09-27T23:48:50.453945000+05:00" level=debug msg="[WG](wg) UDP bind has been updated"
time="2026-09-27T23:48:50.453952000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Starting"
time="2026-09-27T23:48:50.453963000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Routine: sequential receiver - started"
time="2026-09-27T23:48:50.453971000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Sending handshake initiation"
time="2026-09-27T23:48:50.453986000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Sending keepalive packet"
time="2026-09-27T23:48:50.453974000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Routine: sequential sender - started"
time="2026-09-27T23:48:50.453976000+05:00" level=debug msg="[WG](wg) Routine: receive incoming receive - started"
time="2026-09-27T23:48:50.454088000+05:00" level=debug msg="[WG](wg) Interface state was Down, requested Up, now Up"
time="2026-09-27T23:48:50.511122000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Received handshake response"
time="2026-09-27T23:48:50.511420000+05:00" level=info msg="[TCP] 127.0.0.1:52877 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:51.041504000+05:00" level=debug msg="Auth success from 127.0.0.1:52878 -> "
time="2026-09-27T23:48:51.041709000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:51.042498000+05:00" level=info msg="[TCP] 127.0.0.1:52878 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:51.573589000+05:00" level=debug msg="Auth success from 127.0.0.1:52880 -> "
time="2026-09-27T23:48:51.573808000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:51.574642000+05:00" level=info msg="[TCP] 127.0.0.1:52880 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:52.102165000+05:00" level=debug msg="Auth success from 127.0.0.1:52881 -> "
time="2026-09-27T23:48:52.102288000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:52.102815000+05:00" level=info msg="[TCP] 127.0.0.1:52881 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:52.624550000+05:00" level=debug msg="Auth success from 127.0.0.1:52884 -> "
time="2026-09-27T23:48:52.624695000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:52.625115000+05:00" level=info msg="[TCP] 127.0.0.1:52884 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:53.152087000+05:00" level=debug msg="Auth success from 127.0.0.1:52885 -> "
time="2026-09-27T23:48:53.152242000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:53.152785000+05:00" level=info msg="[TCP] 127.0.0.1:52885 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:53.685693000+05:00" level=debug msg="Auth success from 127.0.0.1:52888 -> "
time="2026-09-27T23:48:53.685886000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:53.686593000+05:00" level=info msg="[TCP] 127.0.0.1:52888 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:54.217413000+05:00" level=debug msg="Auth success from 127.0.0.1:52890 -> "
time="2026-09-27T23:48:54.217545000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:54.218055000+05:00" level=info msg="[TCP] 127.0.0.1:52890 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:54.747732000+05:00" level=debug msg="Auth success from 127.0.0.1:52891 -> "
time="2026-09-27T23:48:54.747942000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:54.748726000+05:00" level=info msg="[TCP] 127.0.0.1:52891 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:55.279872000+05:00" level=debug msg="Auth success from 127.0.0.1:52893 -> "
time="2026-09-27T23:48:55.280076000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:55.280779000+05:00" level=info msg="[TCP] 127.0.0.1:52893 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:55.810988000+05:00" level=debug msg="Auth success from 127.0.0.1:52895 -> "
time="2026-09-27T23:48:55.811165000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:55.811886000+05:00" level=info msg="[TCP] 127.0.0.1:52895 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:56.341991000+05:00" level=debug msg="Auth success from 127.0.0.1:52897 -> "
time="2026-09-27T23:48:56.342096000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:56.342538000+05:00" level=info msg="[TCP] 127.0.0.1:52897 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:56.871166000+05:00" level=debug msg="Auth success from 127.0.0.1:52898 -> "
time="2026-09-27T23:48:56.871275000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:56.871765000+05:00" level=info msg="[TCP] 127.0.0.1:52898 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:57.399096000+05:00" level=debug msg="Auth success from 127.0.0.1:52900 -> "
time="2026-09-27T23:48:57.399293000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:57.400102000+05:00" level=info msg="[TCP] 127.0.0.1:52900 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:57.930034000+05:00" level=debug msg="Auth success from 127.0.0.1:52901 -> "
time="2026-09-27T23:48:57.930153000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:57.930659000+05:00" level=info msg="[TCP] 127.0.0.1:52901 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:58.457435000+05:00" level=debug msg="Auth success from 127.0.0.1:52903 -> "
time="2026-09-27T23:48:58.457560000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:58.458024000+05:00" level=info msg="[TCP] 127.0.0.1:52903 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:58.988120000+05:00" level=debug msg="Auth success from 127.0.0.1:52906 -> "
time="2026-09-27T23:48:58.988339000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:58.989126000+05:00" level=info msg="[TCP] 127.0.0.1:52906 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:48:59.518161000+05:00" level=debug msg="Auth success from 127.0.0.1:52908 -> "
time="2026-09-27T23:48:59.518312000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:48:59.518946000+05:00" level=info msg="[TCP] 127.0.0.1:52908 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:49:00.046552000+05:00" level=debug msg="Auth success from 127.0.0.1:52909 -> "
time="2026-09-27T23:49:00.046657000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:49:00.047102000+05:00" level=info msg="[TCP] 127.0.0.1:52909 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:49:00.564665000+05:00" level=debug msg="Auth success from 127.0.0.1:52911 -> "
time="2026-09-27T23:49:00.564792000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:49:00.565212000+05:00" level=info msg="[TCP] 127.0.0.1:52911 --> 10.9.0.1:8080 match Match using wg"
time="2026-09-27T23:49:05.567499000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Sending keepalive packet"
time="2026-09-27T23:49:10.568694000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Sending keepalive packet"
time="2026-09-27T23:49:15.569862000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - Sending keepalive packet"
time="2026-09-27T23:49:17.599277000+05:00" level=info msg="Start initial configuration in progress"
time="2026-09-27T23:49:17.599403000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 3 - started"
time="2026-09-27T23:49:17.599435000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 16 - started"
time="2026-09-27T23:49:17.599445000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 13 - started"
time="2026-09-27T23:49:17.599461000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 6 - started"
time="2026-09-27T23:49:17.599438000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 16 - started"
time="2026-09-27T23:49:17.599441000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 13 - started"
time="2026-09-27T23:49:17.599443000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 17 - started"
time="2026-09-27T23:49:17.599444000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 16 - started"
time="2026-09-27T23:49:17.599446000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 1 - started"
time="2026-09-27T23:49:17.599436000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 13 - started"
time="2026-09-27T23:49:17.599529000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 18 - started"
time="2026-09-27T23:49:17.599448000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 3 - started"
time="2026-09-27T23:49:17.599449000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 8 - started"
time="2026-09-27T23:49:17.599450000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 3 - started"
time="2026-09-27T23:49:17.599450000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 5 - started"
time="2026-09-27T23:49:17.599450000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 12 - started"
time="2026-09-27T23:49:17.599451000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 4 - started"
time="2026-09-27T23:49:17.599452000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 2 - started"
time="2026-09-27T23:49:17.599452000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 8 - started"
time="2026-09-27T23:49:17.599452000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 7 - started"
time="2026-09-27T23:49:17.599453000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 6 - started"
time="2026-09-27T23:49:17.599453000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 14 - started"
time="2026-09-27T23:49:17.599454000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 4 - started"
time="2026-09-27T23:49:17.599454000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 5 - started"
time="2026-09-27T23:49:17.599455000+05:00" level=info msg="Geodata Loader mode: memconservative"
time="2026-09-27T23:49:17.599456000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 6 - started"
time="2026-09-27T23:49:17.599664000+05:00" level=info msg="Geosite Matcher implementation: succinct"
time="2026-09-27T23:49:17.599459000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 18 - started"
time="2026-09-27T23:49:17.599460000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 1 - started"
time="2026-09-27T23:49:17.599710000+05:00" level=info msg="Initial configuration complete, total time: 0ms"
time="2026-09-27T23:49:17.599463000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 18 - started"
time="2026-09-27T23:49:17.599464000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 8 - started"
time="2026-09-27T23:49:17.599465000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 10 - started"
time="2026-09-27T23:49:17.599465000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 1 - started"
time="2026-09-27T23:49:17.599466000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 7 - started"
time="2026-09-27T23:49:17.599467000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 10 - started"
time="2026-09-27T23:49:17.599468000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 15 - started"
time="2026-09-27T23:49:17.599468000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 11 - started"
time="2026-09-27T23:49:17.599469000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 7 - started"
time="2026-09-27T23:49:17.599470000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 2 - started"
time="2026-09-27T23:49:17.599470000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 4 - started"
time="2026-09-27T23:49:17.599471000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 14 - started"
time="2026-09-27T23:49:17.599455000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 11 - started"
time="2026-09-27T23:49:17.599471000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 9 - started"
time="2026-09-27T23:49:17.599472000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 12 - started"
time="2026-09-27T23:49:17.599473000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 17 - started"
time="2026-09-27T23:49:17.599475000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 12 - started"
time="2026-09-27T23:49:17.599476000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 15 - started"
time="2026-09-27T23:49:17.599477000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 9 - started"
time="2026-09-27T23:49:17.599477000+05:00" level=debug msg="[WG](wg) Routine: TUN reader - started"
time="2026-09-27T23:49:17.599478000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 15 - started"
time="2026-09-27T23:49:17.599478000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 11 - started"
time="2026-09-27T23:49:17.599479000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 14 - started"
time="2026-09-27T23:49:17.599479000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 2 - started"
time="2026-09-27T23:49:17.599480000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 17 - started"
time="2026-09-27T23:49:17.599447000+05:00" level=debug msg="[WG](wg) Routine: decryption worker 5 - started"
time="2026-09-27T23:49:17.599458000+05:00" level=debug msg="[WG](wg) Routine: handshake worker 9 - started"
time="2026-09-27T23:49:17.599459000+05:00" level=debug msg="[WG](wg) Routine: event worker - started"
time="2026-09-27T23:49:17.599461000+05:00" level=debug msg="[WG](wg) Routine: encryption worker 10 - started"
time="2026-09-27T23:49:17.601360000+05:00" level=info msg="Sniffer is closed"
time="2026-09-27T23:49:17.601386000+05:00" level=info msg="Start initial compatible provider default"
time="2026-09-27T23:49:17.616096000+05:00" level=debug msg="Auth success from 127.0.0.1:52942 -> "
time="2026-09-27T23:49:17.616185000+05:00" level=debug msg="[Rule] use default rules"
time="2026-09-27T23:49:17.616206000+05:00" level=debug msg="[WG](wg) UAPI: Updating private key"
time="2026-09-27T23:49:17.616302000+05:00" level=debug msg="[WG](wg) peer(xcs7…27mk) - UAPI: Created"
time="2026-09-27T23:49:1