Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm attempting to host multiple website locally with HTTPS enabled, but in order to do this I'd need to configure my local machine to use multiple IP address for localhost (I believe). Is there any way to have multiple IP addresses resolving locally at the same time?

I am using OS X 10.6 (standard edition - not server), and the MAMP server setup.


share|improve this question

3 Answers 3

up vote 3 down vote accepted

You don't need multiple ip in order to host multiple websites on one web server. You need to use "Virtual Hosts" (with https if you need also it). Here there is a guide for virtual hosts on MAMP

share|improve this answer
To host multiple sites with HTTPS enabled I believe they each need a separate IP address. See:… – user1086746 Jun 27 '12 at 16:01
@user1086746 Apache supports TLS Server Name Indication, as do all major client browsers on.. pretty much every OS that's not Windows XP. The answer you should have gotten on your linked question is to set NameVirtualHost *:443. – Shane Madden Jun 28 '12 at 1:01
@Shane that still doesn't appear to work when dealing with multiple sites using HTTPS over the same IP address. I did post what ended up working for me. – user1086746 Jun 28 '12 at 15:12
@user1086746 It most certainly works; I'm guessing your NameVirtualHost didn't match your <VirtualHost> blocks, if you were binding specifically to No matter in this case since you've found a working solution, but NoNoNo is right - you don't need extra IPs. – Shane Madden Jun 28 '12 at 15:30
Well, I would like to get this working 'correctly' as setting up those IP addresses are an extra step. I have 2 NameVirtualHosts like: NameVirtualHost *:80 NameVirtualHost *:443 and have tried using vhosts like: <VirtualHost _default_:443> and <VirtualHost>, but neither will provide an HTTPS connection after the first listed vhost. I could provide the full ssl.conf and vhost.conf files if you were interested! – user1086746 Jun 28 '12 at 15:43

To alias localhost, you can use this terminal command to create a 'loopback':

ifconfig lo0 alias

With the localhost alias setup, you can create multiple HTTPS virtual hosts thusly:

<VirtualHost> ...... </VirtualHost>
<VirtualHost> ...... </VirtualHost>

You could also initialize these hosts on startup, if desired, through root's cron:

sudo crontab -e
@reboot ifconfig lo0 alias

Hopefully this helps anyone running into the same issues I did!

share|improve this answer
Thanks a lot, that's exactly what I was looking for! – vdboor Jul 3 '13 at 8:25
Using echo PASSWORD is a terrible idea. A crude alternative would be to put something in root's cron like sudo crontab -e and @reboot ifconfig lo0 alias There is certainly a more elegant solution, but anything that involves your password in plain text is unacceptable. – chmac Apr 10 '14 at 11:46

You never need to add additional IP addresses to the local host on any operating system (Unix like, Windows, whatever). They will all respond by default, without additional configuration, to all IP addresses from

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.026 ms

So just make your application listen on any IP from the range and you shall be good to go.


One console:

$ nc -vvl 9022
Connection from port 9022 [tcp/*] accepted

Another console:

$ echo Hello | nc -vv 9022
nc: connect to port 9022 (tcp) failed: Connection refused
$ echo Hello | nc -vv 9022
Connection to 9022 port [tcp/*] succeeded!
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.