I have installed two things :

A wi-fi access point through this tutorial:

And an Apache server from this tutorial:

Now, from my phone for example, I can freely connect to my wi-fi access point and then access the Apache server using the address

But I do not know how to assign a hostname, so that I can access my Apache server using a link like


instead of
  • on the machines you want to connect from add an entry to the hosts file (google for how to do this based on your OS and version. The Pi already has a hostname which you can check with the hostname command and you can change this if needed via raspi-config. You may also want to add a hosname entry to the hosts file on your Pi as well. Feb 26, 2017 at 14:28

2 Answers 2


As Steve Robilliard has stated the Pi already has a hostname, raspberrypi by default.

You should be able to address it with raspberrypi.local, although this relies on the avahi service (which is running on normal Raspbian). The use of it is discusssed in How do I set up networking/WiFi/Static IP.

If you want to change the hostname, it is STRONGLY recommended that you do this with raspi-config, which correctly changes ALL the files needed.

If you do it manually BOTH /etc/hosts and /etc/hostname need to be consistent (or you will get inexplicable error messages from some commands).


You can set the hostname that the Apache webserver responds to using the ServerName directive in the Apache config file.

For example:

ServerName my-raspberry-pi:80

(on port 80)

However, unless the hostname is defined in a public DNS server (that points to your local Apache webserver), then you also need to configure the HOSTS file on each machine from which you want to access the Apache webserver and set the IP address that should be used for this hostname. For example:  my-raspberry-pi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.