23

I run rails servers at ports 3000 and 5000.

What do I use (or how do I find) the IP address of my Mac?

Not the one used for web browsing which is my companies host supplied IP but rather my local machine one.

I imagine it would be 192.168.x.x?

8 Answers 8

12

I can't believe nobody has suggested the simplest method of all, only 2 clicks (or 3 if your adapter isn't at the top of the list).

Click System Preferences, click Network.

It will display the IP address of the adapter under Status to the right of the network adapters. If your device isn't at the top (which will be the default selected) then simply click on the one with the green status. It's going to be either Wi-Fi or Ethernet.

1
  • As an aside, this only shows me an IPv4 IP address, while my Mac also has IPv6 enabled (giving me one temporary address and one private fixed one, all nicely shown in ifconfig, or in the TCP/IP tab after clicking Advanced in the Network settings—though the latter does not tell which IPv6 address is which).
    – Arjan
    Aug 11, 2012 at 12:51
17

There are several methods...

...but some methods give different kinds of IP addresses. Make sure you know which kind of IP address you need. For many (most?) purposes, the public IP address is what's required.

  • Your public IP address is the one people on the internet will see. (This is usually what people mean if they don't specify which kind of IP address.)
  • Your local IP address is the one that your router uses to communicate with you on your local area network.

Note: in certain situations, your local IP address may be the same as your public IP address.

Here's a few ways to get each kind of IP address:

#1: From the WiFi menubar -- gives your LOCAL IP address

Hold option and click on the WiFi icon in the menubar at the top-right corner of your screen. You will see a special menu that lists, among many other things, your IP Address.

somebody's screen capture

#2: From Network Preferences -- gives your LOCAL IP address

There are two ways to get to Network Preferences:

  1. Click on the WiFi icon in the menubar, then select "Network Preferences"
  2. Go to the System Preferences (either on your Dock at the bottom of the screen or by searching for it with Spotlight), then open "Network".

You'll see your IP address as shown: somebody's screenshot of their Network Preferences window

#3: From a terminal (Method A) -- gives your LOCAL IP address

Fire up your favorite terminal (e.g. Mac OS X comes with one called Terminal), and type the following:

  • ipconfig getifaddr en0 if connected via a wireless connection.
  • ipconfig getifaddr en1 if connected via ethernet.
  • ipconfig getifaddr en3 if connected via a Thunderbolt-to-ethernet adaptor.

#4: From a terminal (Method B) -- gives your PUBLIC IP address

Fire up your favorite terminal (e.g. Mac OS X comes with one called Terminal), and type curl http://ipecho.net/plain; echo.

#5: From a browser -- gives your PUBLIC IP address

There are many websites you can use that will tell you your public IP address. The simplest is probably a Google search for "what is my ip address".

2
  • 3
    wow, hold option key is so nicely hidden but reveals so much information. thanks for sharing Apr 22, 2019 at 12:47
  • AWesooooomeeeeee....
    – Gupta
    Aug 31, 2022 at 17:43
16

I used:

ipconfig getifaddr en1
4
  • 9
    or en0, depending on the interface used
    – nohillside
    Aug 9, 2012 at 17:42
  • 1
    This is the correct answer.
    – Matt
    Aug 16, 2013 at 19:36
  • If you are using a Thunderbolt-to-ethernet adapter, use ipconfig getifaddr en3.
    – jvriesem
    Oct 22, 2015 at 15:34
  • Use ifconfig -l | xargs -n1 ipconfig getifaddr so you don't have to care about which interface is in use. apple.stackexchange.com/questions/20547/… Jan 11, 2022 at 17:35
6

Alternatively, you could try running

ifconfig

in the terminal. It will show a list of interfaces with IPs by default, along with many many other details such as physical addresses. It can also be used to configure network adapter settings, the man page is here: http://linux.die.net/man/8/ifconfig

or you can run man ifconfig on the terminal.

In your case you're probably looking for en0 or en1, look under inet for the IP address.

2

I installed iStat Menues. Now I can see all the IPs, the one from my provieder is called "public ip" and the in the WiFi network is called "private ip" in iStat Menues.

It could also work with the iStat Nano Widget. Only tried the full version. I only need to click on the menu bar item to get the info.

enter image description here

1

All these answers are good... I'd like to add one thing. If you're trying to get your Mac's IP so you can access the server you're running locally on the same Mac, you can use http://127.0.0.1/ (the local loopback IP) or http://localhost/. It is always the same and you can use it without even being connected to any network.

If you're trying to let others connect to the server on your Mac it would likely be easier to give them your hostname which you can set from the Sharing System Preferences pane (at least as long as they are using a Bonjour-enabled system). Then you can access something like http://mymacbook.local/

1
  • Access via system name requires Bonjour on the "other" computer.
    – nohillside
    Aug 10, 2012 at 8:01
0

You can also go to "About this Mac" and click on the grey text under "Mac OS X" until it displays your local IP address for OS's before Lion.

Also, for Mac OSX versions before Lion, this action also works at the login screen.

5
  • Note to future readers: The other answers here are not wrong; this answer is just the easiest way to find the information (IMHO).
    – Matt
    Aug 10, 2012 at 7:16
  • I never even knew this way existed, so I thought I'd give it a try, and it doesn't work for me on 10.8, it displays the version, serial number, and the build, nothing more.
    – AlanJC
    Aug 10, 2012 at 8:33
  • @AlanJC I assume you are connected to the internet, right? It may be that this is something that was discontinued in ML :(
    – Matt
    Aug 10, 2012 at 9:04
  • Yeah connected over wifi to an airport extreme, early 2011 15" mbp. I won't miss it though as I never knew it existed in the first place.
    – AlanJC
    Aug 10, 2012 at 10:15
  • -1 Yeah it shows me the version number serial number and build but not the ip Aug 10, 2012 at 18:49
0

ifconfig en0 inet

Use ifconfig , then followed by the interface. Use man ifconfig to know more.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .