/etc/hosts file problem on Plasma 21.2.1

Hi all,
I’m running webapp on localhost and I’m trying to point example.local to localhost.
At first it seems easy, previously I was using Ubuntu, but I cannot get it to work properly on Manjaro.
My hosts file looks like this:  localhost  myhostname  example.local
::1        localhost ip6-localhost ip6-loopback
ff02::1    ip6-allnodes
ff02::2    ip6-allrouters

If I try to run it in Firefox it tells me that “We can’t connect to the server at example.local”
Also, when I change it like this, It points to localhost normally, but my server is configured to work on example.local

(...)  example //without .local

I need to have it configured as example.local

Please do not use the domain .local , it is reserved for multicast dns.

Oh I did not know that, btw I’m curious why Ubuntu let me use that domain but on Manjaro it’s forbidden?

It is not really forbidden. But it depends on what services do you use for DNS. And how your nsswitch.conf is configured. It is still not a good idea to use a .local domain in such a way.

For example, on a system without avahi and systemd-resolved it works as expected.

Do you use systemd-resolved?

I’m not sure how the nsswitch.conf looks on Manjaro at the moment. But recently, the files option has been put at the back on Arch. This is one of the reasons you might have this problem at the moment. If you put the files option ahead of resolve and mdns_minimal, maybe even at the beiging of the hosts line, it should start to work.

1 Like

Thank you so much for your answer!

TL;DR: Go to /etc/nsswitch.conf comment line hosts: (...) and replace it with hosts: files mdns4_minimal [NOTFOUND=return] dns

So if anyone had same issue on Manjaro, check your /etc/nsswitch.conf there is slight difference in Ubuntu and Manjaro:


# /etc/nsswitch.conf
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd: files systemd
group: files systemd
shadow: files
gshadow: files

hosts: files mdns4_minimal [NOTFOUND=return] dns
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: nis


# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.

passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd

publickey: files

hosts: mymachines mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files

In order to make .local domain to work change hosts: section in Manjaro to that in Ubuntu

It is better to just move the files options after mymachines and not replace it the complet line. The Ubuntu nsswitch is not set up for modern software.

hosts: mymachines files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname dns

Oh yeah so adding files after mymachines also works, thanks @xabbu!
Also article on Wikipedia with .local was really helpful in solving this

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.