Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some remote SMTP server I am trying to deliver mail to refuses to accept the HELO from my server:

504 5.5.2 <localhost>: Helo command rejected: need fully-qualified hostname

Apparently, my Exim4 server sends localhost as its FQDN. Searching the net and a bunch of config files, I have learned that the value sent as FQDN during HELO is drawn from the primary_hostname configuration variable.

My question is: what is the correct way to change this variable in a Debian system? I guess I can simply hardcode a value in on of the Exim4 config files, but IMHO it would seem to make more sense if the value automagically corresponded to /etc/mailname or some other centralized name config.

I have a feeling that the answer to my question can be found in this text from the Debian wiki:

The name used by Exim in EHLO/HELO is pulled from configuration option primary_hostname. Debian's exim4 default configuration does not set primary_hostname. Exim then defaults to uname() to find the host name. If that call only returns one component, gethostbyname() or getipnodebyname() is used to obtain the fully qualified host name.

If your Exim HELOs as localhost.localdomain, then you have most probably a misconfigured /etc/hosts created by some versions of the Debian installer. In this case, please fix your /etc/hosts.

Unfortunately, I am not familiar enough with Linux server administration to know exacly what all this means :(

share|improve this question
up vote 15 down vote accepted

Your /etc/hosts file should have at least two records in it. The first record should be of the form:


the second one should be of the form: localhost

You also need to make sure that your /etc/hostname file contains the server's FQDN, and that running hostname -f returns your servers FQDN. If you make sure all of this is correct, and restart Exim, you should start seeing it HELO properly.

share|improve this answer
I have changed /etc/hostname from a local machine name to the FQDN. hostname -f still reports "localhost". The part about /etc/hosts in your answer seems buggy - what is the first record supposed to look like? – Jørn Schou-Rode Jul 27 '09 at 16:08
While hostname -f still reports "localhost", it seems that the change to /etc/hostname did the trick - I am able to deliver my mail now. I still would like to see the missing part of your post though :) – Jørn Schou-Rode Jul 27 '09 at 16:15
Oops! Formatting flub. Fixed :-) – Paul Lathrop Jul 27 '09 at 16:37

The primary hostname is prompted for during the installation of exim4. You can run the command

sudo dpkg-reconfigure exim4-config

to go through the prompts again.

As far as I know, if you're already using the 'split configuration' (lots of little files under /etc/exim4/conf.d) and opt to stick with that when prompted, dpkg-reconfigure shouldn't overwrite any of your existing config alterations other than to the settings it prompts you for, but, as ever, you should take a backup first to be safe.

share|improve this answer
It only seems to ask for a "mail name [which] should be the single, fully qualified domain name (FQDN)". However, this setting is correct already, and the HELO still seems to say "localhost". – Jørn Schou-Rode Jul 27 '09 at 16:06

If you use a single configuration file, set the PRIMARY_HOST_NAME variable to the desired name:

For example in /etc/exim4/exim4.conf:


or set MAIN_HARDCODE_PRIMARY_HOSTNAME in update-exim4.conf.conf if you are using split file configuration.

To be safe, restart exim.

share|improve this answer
Just a note that the host listed can't be in quotes, otherwise exim sends HELO '' which breaks sending mail to Google, perhaps others. – mkomarinski yesterday

after adding the the same string in /etc/hosts, hostname -f will return your FQDN

share|improve this answer

I have the same problem. I need to change the mail hostname, because some emails fails, when them was sended. Whith this error:

host []: 550 <>: Sender address rejected: Domain not found

So I change it into the /etc/exim.config the param primary_hostname

Some code of this file:

smtp_connect_backlog = 50
smtp_accept_max = 100

#primary_hostname = 
deliver_queue_load_max = 3
share|improve this answer
Hah, this post helps me with "primary_hostname" and now my exim works better than ever :) – T0m3kk Nov 6 '14 at 9:35

in WHM goto Exim Configuration Manager -> Advanced Editor

scroll down until you find "Add additional configuration settings" (a big blue button) and click it.

in the new line, add [ primary_hostname ] = [ ]

scroll to the bottom and click Save.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.