After weeks of trying I finally solved this problem. I am putting my answer here.
The problem is actually caused by some unknown firewall issue within the macOS. The solution for this is to reinstall the entire operating system ... I know this sounds stupid and troublesome, but the problem is solved after that.
The motivation for doing so is that I happen to notice I do not have access to some of my folders under the home directory (I tried to use sudo
to modify some files but was not granted access). This is my personal laptop and there is not supposed to have such issue. I then realize that this Mac was synced from my old Mac. The syncing process might cause some firewall issues.