Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

By default 127.0.0.1 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 http://127.0.0.1:3000?
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. 127.0.0.2), 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 (httpd.apache.org/docs/1.3/vhosts) 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

1 Answer 1

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:

127.0.0.1 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
1  
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

 
discard

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.