Find Your Local IP Address on Your Mac
ipconfig getifaddr en0 (primary)
ipconfig getifaddr en1 (secondary)
How do I know which to use?
It is common for Mac laptops to have one (wireless only) or two (wired and wireless) network connections. When a wired connection is present, it is the primary connection (with wireless as secondary). When there is only wireless, that is the primary connection.
From the command line: ipconfig
Why would you want to find your local IP address?
My use case is I develop websites locally on my machine (i.e. instead of running on a server on the internet, the website I’m working on is just on my machine). I can load these sites at http://localhost/ or http://127.0.0.1/, which works great. However, I also need to test the sites on IE (since occasionally IE does not render the same as other browsers). To this end, I’m running Virtual Box with an instance of Windows 7 on my machine. The problem occurs when I try to load the local site in Virtual Box at http://localhost/, this does not work. Inside Virtual Box localhost refers to my Virtual Machine not my real machine running it (this is starting to feel a little like Inception). The solution is not to load the site at localhost nor 127.0.0.1 but instead to use the IP address assigned to my machine by the local network. For example currently my machine is at http://192.168.1.105/ on my local network. Solved. New problem, how do I determine the IP address on my local network.