Hostname issue with Postfix Webmin module

I usually avoid using Webmin, but I had to set it up for a company I worked for.

The guys there were not familiar with Linux and they needed an interface to keep configuring the Postfix server I settled (with Spamassassin as an antispam and Amavis as content filtering).

I had to face a problem while I was trying to get the Postfix Webmin module working.


The error message was quite cryptic. Just this single line on a blank screen every time I tried to apply a configuration change :
usr/sbin/postconf: fatal: gethostbyname: Success

After looking on the net, I learned that this Webmin module uses the getbyhostname() function to resolve the server name, instead of using the DNS service as Postfix do.

Therefore, the message indicates that the machine name could not be resolved for some reason.
There are several possibilities.

First, check your /etc/hosts file, it must contain your machine name

Then, in your /etc/postfix/main.cf configuration file, you might have this line (especially on Debian systems) :

myorigin = /etc/mailname

If so, check that /etc/mailname contains your machine name, as /etc/hosts do.

Finally, also check that in /etc/postfix/main.cf, the myhostname field is correct :

myhostname = mail.phocean.net
myhostname = mail.phocean.net

If you made any change in main.cf, restart postfix and that should be fine !