How can I trace the macOS network stack?
Try to install Wireshark.  Maybe monitoring the actual network activity will give you a clue (it will probably show an outgoing packet or connection that isn't answered).