I am having trouble accessing a NodeJS server that is running local on port 4000. I can access the server via chrome as http://localhost:4000, however I cannot access via the IP http://192.168.30.30:4000. I am also trying to access the local web server from an android simulator and cannot.
I have allowed chrome and android studio access to local networks via settings -> privacy -> local network. After allow this access I have restarted both chrome and android studio. I have also restarted my mac. In addition I have wiped the network permissions such that they can be reset following https://forums.macrumors.com/threads/local-network-access-nightmare.2448144/?post=33698401#post-33698401.
To reset Local Network permissions, from Terminal in Recovery delete /Library/Preferences/com.apple.networkextension.plist
rm "/Volumes/Macintosh HD/Library/Preferences/com.apple.networkextension.plist"
That did reset the permissions such that I could grant again but I still cannot access the server via IP.
I have read a ton of post about Sequoia and no access to local servers via IP, yet I still have had zero success fixing this issue.
Anyone have any other ideas I can try?
EDIT:
I have tried starting my node server in a few ways:
server.listen(4000, 0.0.0.0, () => {...
And
server.listen(4000, 127.0.0.1, () => {...
I understand the syntax on deleting the plist file is not perfect, just know that I was able to delete and was promoted appropriately for local network access on chrome and android and did accepts
While the addresses http://localhost:4000
and http://192.168.30.30:4000
may seem equivalent, since they both end up pointing to the same location, they do so in different ways. localhost:4000
refers to directly on your device; the "loopback" address. 192.168.30.30:4000
will search through your network interface, and work with the router to find this port. These can both be done, but there's a bit of nuance to how they're done.
To call directly on your device at http://localhost:4000
, you can do as you've been doing. Calling server.listen(4000)
will allow this as well from your host NodeJS server.
Conversely, to access http://192.168.30.30:4000
, you should take the following steps to make sure this is allowed and configured properly.
server.listen(4000)
, call server.listen(4000, '0.0.0.0')
. This will allow it to recognize that the server is being hosted on a local IP address, regardless that it is on your device or "local host."http://192.168.30.30:4000
If this still does not work, and even entirely disabling the firewall and checking Google Chrome's Privacy settings has not fixed this issue, I advise finally checking the way you're deleting this file.
The command rm "/Volumes/Macintosh HD/Library/Preferences/com.apple.networkextension.plist"
will either do nothing or cause an error. To fix this, instead use escape codes for spaces, specifically in Macintosh HD
, and remove the quotation marks.
Keep in mind, I highly discourage deleting system files unless absolutely certain it will not cause issues. This can cause serious issues on your device, and there are almost always safer ways to do this.
rm /Volumes/Macintosh\ HD/Library/Preferences/com.apple.networkextension.plist
Plists are also human readable. While I discourage directly editing any file, you may be able to manually adjust the adverse settings and fix the issue manually.