MacOS – How to access web dev servers running on localhost with non-standard ports from the network

macosNetwork

On one Mac in my household I develop applications with various tools like Jekyll or Meteor. They usually have their own default ports for their development web servers; Jekyll uses 4000, Meteor 3000, and so.

So on that Mac I'd go to 127.0.0.1:4000 (or localhost instead of the IP address) to access my application. I have another Mac on the same LAN and I'd like to see that too. I thought it'd just be 192.168.0.164:4000 (for example), but that's not working. Pinging that IP works fine though, and so does SSHing (if I enable it in Sharing). I thought the 192.168.0.164 therefore would just translate to that Mac's localhost and the ports and HTTP would work fine.. I'm clearly missing something.

They're both pretty much fresh Macs: not much installed software. The firewall was off by default. I couldn't see anything in System Preferences > Sharing that seemed appropriate. How can I get 192.168.0.164:4000/3000/whatever port working?

Best Answer

This may be considered a duplicate question as I arrived at the solution from this answer.. I didn't give up searching, sorry about that.

To help others I'll mention what I got wrong.

I didn't have to change any firewall or sharing settings - it was to do with where the application was being hosted. I assumed that when I viewed 192.168.0.164 from the other Mac, it'd magically map to the host's 127.0.0.1... that is not the case!

So instead I explicitly hosted the application on 192.168.0.164 instead of 127.0.0.1 and it worked fine!