Debian 12/Bookworm headless host

I have a local container running with an IP of I can access the container via IP:

root@dev ~# ping -c2
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.088 ms
64 bytes from icmp_seq=2 ttl=64 time=0.092 ms

--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1018ms
rtt min/avg/max/mdev = 0.088/0.090/0.092/0.002 ms

I can also access the container via IP using curl:

root@dev ~# curl --insecure                                          
The provided host name is not valid for this server.

But as per that message, I need to connect to the container via a domain name (configured as an allowed domain in the software), not IP. For testing, I have configured a fake domain: fake.domain.com.au. I have added it to my /etc/hosts file:

root@dev ~# grep fake.domain.com.au /etc/hosts

However, I can not access my container via that domain?!:

root@dev ~# ping -c2 fake.domain.com.au
ping: fake.domain.com.au: Name or service not known
root@dev ~# curl --insecure https://fake.domain.com.au
curl: (6) Could not resolve host: fake.domain.com.au

I've search high and low for an answer and am coming up blank. Following other threads I've found, here is some further info:

root@dev ~# cat /etc/nsswitch.conf 
# /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
group:          files
shadow:         files
gshadow:        files

hosts:          files dns
networks:       files

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

netgroup:       nis

Just in case it matters (it shouldn't IMO) I am using resolvconf for DNS (not systemd-resolve):

root@dev ~# apt policy resolvconf systemd-resolved
  Installed: 1.91+nmu1
  Candidate: 1.91+nmu1
  Version table:
 *** 1.91+nmu1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status
  Installed: (none)
  Candidate: 252.12-1~deb12u1
  Version table:
     252.12-1~deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages

I also came across another post which appeared to be a similar issue and apparently a reboot resolved it?! But my issue still remains after a reboot :(

1 Answer 1


Face palm

In the process of writing this issue up, it became apparent what my problem was. In the /etc/hosts file, the format is:


I was setting it the other way around... Doh!

Initially I was going to just close this draft and hide my shame. But perhaps it will save somebody else (who obviously hasn't had enough coffee either) from wasting tons of time on the same silly mistake.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .