Raspberry Pi 4 Avahi Trouble - Hostnames not working

Hello, I am having some trouble with my Raspberry Pi4 Running manjaro with KDE Plasma.

Basically using hostnames instead of IPs is not working across a variety of applications. On the raspberry pi, I can ping/ssh itself using its hostname but I cannot do the same to any other computers on my network from the raspberry pi. I also cannot ping or ssh into the raspberry pi from any other computers on my network using its hostname. The host name is unique, and I have tried some trouble shooting steps without any luck.

If I install Ubuntu on the same Pi everything works as I’d expect (but much slower).

Here is my /etc/hosts file, I have no idea how it should be configured:

# Host addresses  localhost  pi4-server
::1        localhost ip6-localhost ip6-loopback
ff02::1    ip6-allnodes
ff02::2    ip6-allrouters

Do I need to manually add every ip address and hostname to this file? That kind of defeats the purpose of using hostnames as the local IP address may change.

Any help is appreciated, and if you need any more information let me know the paths to find it.

Yes. What I do here is reserve ip address for the computers I need in the router so they get the same address assigned every time. You will need each computers MAC address for the router where you can get it with ip addr show. Example:

70:85:c2:33:1c:a2    pi4    desktop    vim3    rock64

Is that really the only solution? Is there no way for Manjaro to automatically use hostnames to connect to other computers on a local network like every other OS does? Even then, how do I connect to thee raspberry pi from other OSes (MacOS/Windows) using its hostname? What does Ubuntu do to get all of this to work without having to configure anything?

You can use Avahi. Make sure it is installed and enabled(avahi-daemon.service started at boot). If you use a firewall, make sure you open ports related to mDNS.

If you want to query mDNS from your Manjaro system, edit /etc/nsswitch.conf and add at east mdns4_minimal to your host line. (It is maybe already there.) You also need thenss-mdns package.

For more information check the Arch Wiki.