I have experienced this issue frequently not only in Surge but also in ClashX. So, I guess this isn't a Surge related issue.
While investigating the cause of this issue, I came across some logs:
Can't assign requested address ...
That's a very helpful log, which helps to find the following links:
In short, in following cases, the routing table of macOS may be susceptible to corruption:
- changing networks while having the Enhanced Mode enabled.
- putting the device to sleep and waking it up to a different network.
- ...
The solution is to flush the routing table:
- one way is to reboot, as you said.
- another way is to run some commands as root, like:
# This is the outbound interface to Internet.
# Use ifconfig -L to figure out which interface corresponds to WiFi/Ethernet:
#
# * en0 is Ethernet, typically.
# * en0 is WiFi on MacBook without hardware Ethernet.
INTERFACE=en0
# take the outbound interface down
ifconfig "$INTERFACE" down
# flush the route table
route -n flush
# take the outbound interface back online
ifconfig "$INTERFACE" up
You can still use tun device, everything will be fine. 😉