Confusion about sendmail and /etc/hosts

I'm definitely a Linux newb so forgive me if this is a silly question ;)

My Linode is running Ubuntu 9.04.

A few months ago I installed sendmail and in order for it to work I modified my /etc/hosts to be like this:

**** localhost.localdomain localhost [hostname] [hostname].localdomain

[IP] [external hostname]****

I don't understand why I did that, I just read it somewhere and it seemed to work.

Then about a month ago I realized many of the emails coming from my primary domain were being marked as spam because the headers had:

Received: from localhost.localdomain (localhost.localdomain [])

So I edited the /etc/hosts again and modified the first line to be: [domain] localhost.localdomain localhost [hostname]

(I added the domain name that the emails were coming from to the first line)

This seemed to help. The email headers looked better and I was getting a lot less bounces.

However, today I rebooted my server and that latest /etc/hosts change took down my domain so a browser just showed "It Works!" (I guess I hadn't restarted Apache since then).

So it seems I have two choices:

(1) Be able to send emails that actually arrive at their destination

(2) Have a website that's actually live

I'm hoping there's a 3rd option that lets me have both :)

6 Replies

It's certainly possible that there's something about Apache that I don't know, but I can't think of any way that change would lead to what you're describing. Is it possible there was some other change to the Apache config since the last reboot? You could find out for sure, of course, by switch /etc/hosts back, rebooting, and seeing what your Web page looks like.

Oh sorry, I didn't explain myself properly.

It definitely was that change because I've already removed my domain from the first line in /etc/hosts, restarted Apache and my site is up again.

I'm also totally confused why that would cause the "It Works!" problem :(

I'm having a similar problem.

Email sent by are being rewrited in something like

My hosts.conf is as follow: localhost

If I delete in my hosts.conf, then when trying to reach with a broswer, I obtain "It works". With, it still work.

The Apache virtual host in charge of this domain looks like that:

  <virtualhost *:80="">ServerName

Any ideas ?

Edit /etc/hosts localhost.localdomain localhost server

Where: is replaced by the real IP address assigned to your Linode.

server is replaced by the name of your host in /etc/hostname (can be anything you want) is replaced by your real domain name.

This is what I have in my /etc/hosts. Start with that and move forward.


I'm having a similar problem.

Any ideas ?

Edit /etc/apache2/sites-available/default

Default virtual host - replaces main server

Setup other virtual hosts pointing to the users home directory

Edit /etc/apache2/sites-available/



DocumentRoot "/home/girlie/public_html"

ScriptAlias /cgi-bin/ /home/girlie/cgi-bin/

Replace domains and users to match yours.

Then run a2ensite with the domain file name.

thank you, problem solved :)


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct