Finding the Pi's IP Address


#1

You should be able to access your PI/OctoPrint from a device running macOS or iOS (iPhones, iPads) without the IP address by using <hostname>.local in your web browser or when accessing via SSH (OctoPi's default is octopi.local). On Windows you should be able to see your OctoPrint instance pop up in the Explorer under "Network > Other Devices". On Linux and Android devices, you will need to access by the IP address.

Finding Your Pi's IP address

Option A: Access your router's set-up/control page

If you have access to your router's set up page, there is usually an option to show all connected devices. The details of doing this are beyond what I'll go into here, since each router brand/model is different. In short, you access the page by entering the router's IP address in your web browser's address bar. The Router's IP address varies, but two commonly used setups are 192.168.1.1 and 192.168.0.1 (or you can find it in your computers network information). You'll most likely need a username and password to log on to your router (get those from your ISP, if they will give that information out). Then poke around the various options. Look for something that says DHCP, or LAN, or WLAN and see if it brings up a list of connected devices. Look for a device named "octopi" in that list (if you have renamed your octopi hostname to something else, look for that name). If you see the name in the list as an active device, your Pi is connected and is using the IP address indicated.

Option B: Use a Network scanner

There are a number of free apps you can download. I use the free Angry IP Scanner (works on Windows, macOS, and Linux - I have not tried running the Linux version on a Pi). Fing is also a good free option (runs on Windows, macOS, Linux - and has a Pi version. You can also find the Fing app for Android and iOS devices.)

Log on to your WiFi network with the device on which you will be running the network scanner app, launch the app and tell it to scan the network. Look through the result for a device named "octopi" (or whatever name you have given your OctoPi setup). Note that some IP scanners will remember devices from a previous scan and show them even if they are not presently on the network (in this case, usually dimmed out). You are looking for active devices. (If you app shows both active and inactive, you can usually set a filter to show only active devices.) If you see the name in the list as an active device, your Pi is connected and is using the IP address indicated.

An advanced option is nmap -p 22 192.168.0.* (or whatever your network prefix is).

Option C: Connect to the Pi via Ethernet

If your Pi is connected to your local network (or directly to a computer) via an Ethernet cable, you can SSH into it to enter commands on the command line. Follow the commands listed under Option D.

Option D: Plug in a monitor and keyboard

You can also access the Pi by plugging in a keyboard and monitor. This is the recommended failsafe if you can't find it with the above options. Log into your Pi and enter the following command on the command line:

ifconfig

If your Pi is connected to the WiFi network, a section of the output should look something like this:

wlan0     Link encap:Ethernet  HWaddr xx:yy:zz
          inet addr:192.168.aa.bb  (followed by other stuff)

The four-part number is the IP address assigned to your Pi by your router for WiFi access. (The "192.168." start of the number is a very common sequence for home WiFi networks. Another common starting number sequence is "10.". Unless you have an unusual network/router setup, yours will likely look similar. Large corporate or school networks will likely be different.)

If the Pi is not connected to a WiFi network, the wlan0 section of the output from that command should start with something like this:

wlan0     Link encap:Ethernet  HWaddr xx:yy:zz
          UP BROADCAST MULTICAST  MTU:1500  Metric:1

In other words, there's no line listing "inet addr:" for wlan0.

If you have connected by Ethernet cable, look for the section starting with 'eth0' instead of 'wlan0'. Reading the output is the same as for the wlan0 entry.

Alternatives to Hunting for an IP Address Each Time:

Unless you have set up a static IP for your Pi, it will most likely change from time to time. If you don't want to have to hunt for the IP address each time it changes, you have several options:

Access Method A: Access your Pi by Name:

The Raspian OS (on which OctoPi is built) comes with Zeroconf installed (Zero Configuration Networking standard), and OctoPrint has a bundled discovery plugin so devices which also have some form of Zeroconf installed (included with Apple iOS/MacOS, can be added to Windows ) should be able to find OctoPrint by entering hostname.local into their browser (in OctoPi this would be octopi.local unless you have changed the default setting). You should also be able to SSH into the Pi using: ssh pi@octopi.local

Access Method B: Set up a Static IP address for your Pi:

A Static IP address assures that your Pi has the same address each time it connects to your network. You still need to remember an IP address, but it will not change over time.

You can set up a Static IP address from your router's configuration page. Since how to do this varies from brand to brand, and even between models within a brand, a how-to is beyond the scope of this post. Try a Google search on your modem's brand and model with the words "Static IP" included to find instructions on how to do this.

It is also possible to have your Pi request a Static IP from your router. (This may not always work, especially on complex networks).

:point_right: To do: add link to instructions for requesting a Static IP from the Pi.

Access Method C: Have your Pi email you its IP address upon Startup:

Your Pi can email you its IP address and a greeting message at each startup. This is one of my favorite solutions, as it both sends the IP address, and the email confirms that the Pi is up and running. Find instructions at this YouTube video: Auto-mailing the Pi's IP.

Click 'Show More' in the video's description to find the text instructions. In the "Running the emailer on Boot" section, do not use the method entitled UPDATED METHOD FOR PIXEL NEW PI. The OctoPi image is based on a 'Lite' version of the Raspian operating system which does not include some of the files necessary for this method to work. Instead, scroll down to line 142: OLD METHOD THAT USED TO WORK WITH OLDER PI.

I did vary their instructions slightly. I set up a separate gmail account for the PI to use, as they suggested (you need to make some changes to the security settings for the account in order for the Pi to have access, and this is not recommended for your main email account). They have the Pi send the email from it's own account and to its own account. I changed the "To:" address in the script to my own email address, since I can receive these emails without lowering the security settings in my own account.

I have used this successfully in OctoPi 0.13 and 0.14. Please reply if you've used this with other versions.

Access Method D: dynip

todo

Access Method E: AWS Route 53

todo


Setting up OctoPrint on Windows
No wired DHCP on new install
#2

external IP for programmatic purposes:

curl 'https://api.ipify.org?format=json'
curl 'https://api.ipify.org'

python3 -c "import requests; print(requests.get('https://api.ipify.org/').text);
python3 -c "import requests; print(requests.get('https://api.ipify.org/?format=json').json());"

etc.

I actually have a cron that sets it in aws route53 and also (repeatedly) uploads a file with the IP to s3 as a backup.


#3

Currently on the go so not editing it in by myself but OctoPrint's bundled Discovery plugin will also announce OctoPrint via UPNP/SSDP in a way which should make it pop up in Windows' network neighborhood. See the plugin's docs.


#4

added to the wiki, foosel.


#5

@tedder42 - Thanks for the edits. It certainly helped the clarity and corrected some of my errors. I made a couple more minor ones (including deleting 'wlan0' from after the ifconfig command in Option D. Since you added the part about an Ethernet connection, we don't want to limit output to just the WiFi section.)


#6

Yeah, I wanted to label the sections to make it easier to point people at various options- especially 'option D'. And you're right about removing wlan0 from ifconfig, of course.


#9

@tedder42 - regarding the "Access method A: Access your Pi by Name" section:

I edited this to reflect that Windows does not ship with any Zeroconf utility installed and included a link to find Bonjour for Windows. I have not used Windows 10 much. Am I correct that Windows 10 also does not come bundled with Zeroconf? Is there a better (or more widely used in the Windows world) Zeroconf utility to link to than Apple's Bonjour?


#10

None that I know of.

Yep. Unless I missed something when I set up my current machine last October. Had to install the "Bonjour Printer Wizard" before Zeroconf/Bonjour/Avahi/mDNS (sooo many names for the same thing!) worked.

However, Windows does have UPNP/SSDP support and as I mentioned, the Discovery plugin supports that as well:

edit

I just read through the post again and am a bit unsure about the order of things.

Normally, users should be able to access things either through octopi.local or via the network discovery. Most Linux distros I've worked with in the past also support octopi.local out of the box, so all major desktop operating systems should already be covered. So I'd prefer this "default" approach to be tackled first, and then explaining alternative methods to find/access the Pi if the default doesn't work for whatever reason (network filter, mobile device).

But I'm currently completely incapable of making a suggestion on how to best structure and phrase that - I tried and failed horribly. TGIF.


#11

I'm going to have to leave that to someone else to write up the Network Discovery process on Windows (I'm happy to help clean up and clarify wording once a draft is done). I'm not really a Windows person. I can get around in it when I have to, but really dislike the basic layout (IMO, they focused too much on "eye candy" rather than intuitive function from about 8.0 onward). I have limited access to Windows machines (I have to remember my kid's password on one of their computers).

It's not clear to me which you mean by the "default approach". Is that using octopi.local? If so, is it true that "all major desktop operating systems should already be covered", since Windows is not covered (at least not by default). Should our instructions be to have Windows users install Bonjour as part of their initial set-up? It would certainly save a lot of messing about with Static IP addresses. However, you lose the ability to access OctoPrint from a random Windows PC (the elementary school where I volunteered for a few years had all of their laptops and desktops locked down so I could not install ANYTHING on them - which is one reason why the web-based TinkerCad was our CAD program of choice, and why I set up the Pi to email us it's IP on startup).

I'm not really familiar with UPNP/SSDP. I don't find any equivalent method on the Mac like the Network screen shot you showed for Windows (from Finder, choosing "Go>Network" does not show anything relating to OctoPi/OctoPrint).

Or is the default approach octopi.local for Mac & Linux, and via Network Discovery on Windows?


#12

This. At least that's the least involved one that should normally not require any additional setup at all on desktop.


#13

Should we re-order the initial post and start with "Accessing OctoPrint on your Pi" and use a slightly rewritten version of the section now entitled "Alternatives to hunting for an IP address each time"?
We'd then have sub-sections named

  • "Access by Name" (i.e. octopi.local)

  • "Access via Network Discovery" (someone needs to write this part)

  • "Access via Pi's IP address" (a brief description of how & where to enter the IP address in a web browser - some people do get confused by that since they may never have entered an IP address before.

That last section would be followed by options for finding the IP address (currently labeled as options A-D, with addition of what is currently labeled as Access methods B & C (which are really just variations on accessing via, or obtaining, the IP address).

I'm not sure where "dynip" and "AWS Route 53" fit in, since I'm not familiar with them.


#14

@John_Mc that's a good summary of what I had in mind but was unable to put in writing so far! I could take care of the network discovery bits.


#15

I'll start poking around at it when I get a chance.


#16

Is there a way to temporarily set a page as "private" so I can work on a draft and get it at least roughly formatted without messing up this page? Then when I'm done, I coudl replace the first post on this page with the new text.


#17

@John_Mc no, but you could just copy paste the full contents into a private message to yourself (or if it doesn't let you do that to discobot or me)