sajad torkamani

In the terminal, run:

ipconfig getifaddr en0

This should output something like:

192.168.0.89

Now, you should be able to access your machine’s localhost from any other device connected to the same WiFi network.

For example, if you’ve setup Nginx with Homebrew and not changed the default configuration, then you should be able to access the default Nginx landing page on the local IP address (output of ipconfig getifaddr en0) on port 8080 from any other device on your network.

Bonus: add shell alias

You might find it easier to create a Bash or ZSH alias. Something like:

alias myip="ipconfig getifaddr en0"

Now, you can just type myip.

Access localhost from external networks

If you want to access your localhost from a device that’s not connected to the same WiFi network, you can use a tool like Ngrok.

Tagged: macOS

Leave a comment

Your email address will not be published. Required fields are marked *