What should my /etc/hosts look like?

Linode Staff

My /etc/hosts file contains the following: localhost.localdomain localhost
123.456.78.90 hostname.example.com hostname

I set my server's hostname to myserver and bought the domain mydomain.online. What do these lines mean, and what should I change in my own configuration?

1 Reply

The first line contains your loopback address and the names you can use to access the local machine as a remote one. If you were to install a browser on your Linode and access it through Glish, a service on your Linode could be reached at localhost.localdomain and would respond to the name localhost.

The second line should contain your Linode's IP address, as well as any associated names to which the Linode will respond via the IP address. So, in your case, the /etc/hosts entry could look like:

123.456.78.90 mydomain.online www.mydomain.online myserver

The www.mydomain.online bit is optional, but common, as nowadays, websites serve the same content at both mydomain.online and www.mydomain.online.

We've got more info in our Getting Started guide about updating your system's /etc/hosts file.


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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct