Why does FQDN hostname does NOT persist after reboot?

SYSTEM INFORMATION
OS type and version Debian Linux 10
Virtualmin version 7.1-1

Every time the virtual server is rebooted, the hostname changes from server.mydomain.com to just server
Then emails start bouncing…
Why is this happening? How can I make the FQDN hostname server.mydomain.com to persist upon reboot?

How are you changing it after reboot?

Using ‘hostnamectl set-hostname FQDN’ should do the trick.

I have been changing in it via the gui by going to:

Webmin > Networking > Network Configuration > Hostname and DNS Client > Hostname

Is this not the correct place or way to change this?

Hm, I see on my system I only have the first name there also, not FQDN.
But I did have the hostname set before installing Virtualmin, so try the hostnamectl command and let us know if that solves it.

@hisaltesse, @toreskev,

Often when you set the hostname to something like:

server.domain.com

The distro will choose to display it in various areas as:

server

However, email bouncing issues may not be related to the way the hostname is presented, and if it is can be addressed by adjusting the Postfix configuration manually is needed.

If you require assistance, I can offer technical support over a screen sharing session for an affordable rate exclusive to Virtualmin users.

*** Professional, Affordable, Virtualmin Assistance: https://tpnassist.com ***

1 Like

That’s true, but the OP mentions that it starts working after he edits the hostname on that page.
Personally I don’t do system related tasks like this in Virtualmin, so I’m not sure how it’s supposed to look or work.
I just gave him an option that should work across reboots :slight_smile:

I tried hostnamectl set-hostname server.mydomain.com and not only it doesn’t persist but it broke my site. My url no longer load and gives me the error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

How do I undo this command please?

Should be as simple as ‘hostnamectl set-hostname server’ again.
But this probably didn’t break your server, you most certainly have some other weird config (cloudinit maybe?) that’s breaking stuff on boot.

Asuming server.mydomain.com is your server hostname, you shouldn’t have to undo hostnamectl set-hostname server.mydomain.com.

What is the content of your server’s /etc/hosts right now?

 cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

myIP server.mydomain.com server

Seems like your host file is referencing the host name. What does the following commands return after rebooting your server?

hostname
hostname -f
hostname -s
hostname -d

If hostname and hostname with -f returns server.mydomain.com, with -s returns server and with -d returns mydomain.com then your hostname is “most probably” set up correctly.

The “most probably” part is because you also need to make sure that the DNS record for server.mydomain.com is properly set up as well.

first I fixed the issue with the site… it was because postgre failed to start.

In my case after reboot, hostname is server and hostname -f is server.mydomain.com

I am not sure why changing to the full domain does not persist.

Are you using OpenVZ by any chance?

I am using lxc (close to openvz) and the container config is set to server.domain.com

I’m not too familiar with LXC but I’ve had issues with OpenVZ when it comes to persistency of the hostname on reboot. Just like hostname -f, the hostname command should return the FQDN (server.mydomain.com) as well so I have a feeling this might be related to LXC tbh.

Yes Linux Container (LXC) derived from and works like openvz… was there ever a solution for making the FQDN persist in the container?

There’s an older thread in this forum (or in StackExchange) where I had this same issue and somehow found a fix for it but I don’t remember what I did as I ended up switching to KVM later. Let me try to find that thread and see what I did to fix it.

Also, what is the content of your /etc/hosts file?

I’m still curious to see what is “actually” causing the problem, as nothing I am seeing should be causing emails to bounce outright… I suspect there’s something else misconfigured.