Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

By default has the localhost alias.

  1. I found several approaches to changing it to a different string, but what is the standard, effective and safe best-practice way of doing it?
  2. Can I give the same IP, but with a different port, a specific/different alias e.g. when I type marius to get responses from the server listening to
share|improve this question
What software is running behind that port? Most software allows you to change the listening port. – Lekensteyn Feb 14 '11 at 20:54
I'm running WEBrick, the rails embedded web server. But I wanted to also be able to have Apache responding at :8080. Would changing the IP (e.g., and then give that one another alias be a better approach? – Marius Butuc Feb 14 '11 at 21:18
Don't remove the localhost alias. It's likely some applications rely on it. Instead, add more aliases like Josh Taylor shows. – djeikyb Feb 14 '11 at 21:58
@djeikyb thanks for clarifying that up. – Marius Butuc Feb 14 '11 at 22:01
In the apache config, you can configure virtual hosts ( to respond to different domains/aliases. I am sure you know this but there is no way through which you can run two processes listening on the same port. – Khaja Minhajuddin Feb 15 '11 at 16:46
up vote 5 down vote accepted

The only way I know of is to edit your /etc/hosts file.

So for example you could have this: localhost marius

I'm not totally sure on changing port though, as you shouldn't use ports in the hosts file.

share|improve this answer
why shouldn't you use ports in the hosts file? – Marius Butuc Feb 14 '11 at 20:43
The hostfile is used for resolving host names (DNS). For port forwarding, you'll need a solution like IPTables. – Lekensteyn Feb 14 '11 at 20:52

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.