The hostname is the server's network name. A correct hostname should be a fully qualified domain name (FQDN): server.example.com.
Change Hostname (systemd)
sudo hostnamectl set-hostname server.example.com
hostname --fqdn
Update /etc/hosts
sudo nano /etc/hosts
# Add:
127.0.1.1 server.example.com server
YOUR.PUBLIC.IP server.example.com server
Verify the Change
hostname
hostname --fqdn
hostnamectl status
💡 Mail server: The VPS hostname must match the PTR record and Postfix HELO name. Format:
mail.yourdomain.com.⚠️ Never use bare localhost: A hostname of
localhost or an unqualified name causes problems with Postfix, SSL generation, and control panels. Always use FQDN.