How to Change Raspberry Pi Hostname (Rename Your Pi)

A hostname is the name of your computer on a network. Your computer can be reached by its IP address, but those are long and hard to remember. Setting a hostname is easier to remember, more convenient to type, and generally better for managing multiple devices on a network.

By default, the Raspberry Pi hostname is raspberrypi, but if you have multiple Pi's on the same network you'll probably want to set a unique hostname for each. Otherwise, you'll have issues with SSH timing out when attempting to connect.

Certain prebuilt software installations might ship with a hostname that's already been changed. For example, the hostname for RetroPie is retropie and OctoPrint uses octopi by default. I still recommend changing these, using this guide, to avoid conflicts.

1

First, you'll need to log into your Pi and edit the /etc/hosts file and add the desired hostname.

sudo nano /etc/hosts

You'll see a line like this:

127.0.1.1    raspberrypi

Replace raspberrypi with your desired hostname, save, and quit.

As an example, I'll set the hostname to howchoo1. So my /etc/hosts file would contain:

127.0.1.1    howchoo1
2

sudo nano /etc/hostname

By default, this file contains only the name raspberrypi. Again, replace this with your desired hostname. Updating this file will ensure that the hostname remains set upon the next reboot.

For my example I would replace raspberrypi with howchoo1.

Finally, reboot your Pi:

sudo reboot
3

You should now be able to access your Pi using its new hostname.

If you can't, you may need to edit /etc/hosts on your local machine (not the Pi) and append the following:

<pi ip address> <hostname>

If necessary, learn how to find the IP address of your Raspberry Pi.

Now you can reach your Pi using the new hostname.

For our example, my entry would look like this:

192.168.1.181 howchoo1