Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have three IPs. I am trying to bind Apache to two of my IP addresses to leave the third free for other uses(Node.js). At present, Apache is listening on all IP addresses. httpd.conf:

Listen 80

I only want Apache to bind to two of my addresses. I have tried following this doc and replaced the above Listen 80 with the following:

Listen XX.XX.XX.XX:80
Listen XX.XX.XX.XX:80

However, when I try to restart Apache, I get the following error:

Stopping httpd:        [FAILED]
(99)Cannot assign requested address: make_sock: could not bind to address XX.XX.XX.XX:80
no listening sockets available, shutting down

I don't understand how port 80 is free to be used for all IP addresses, but when I specify individual IPs, it errors. Does anyone have any ideas?

Thank you.

share|improve this question

5 Answers 5

up vote 2 down vote accepted

You only need to bind 1 IP address to apache.

Listen [myIP1]:80

Thats all you need.

share|improve this answer
    
I have two IPs that I use for different sites. It is the third IP I need unbound from Apache for Node.js –  Christopher May 24 '11 at 13:51
    
now I get it. Its in the virtual host that you specify the IP address. As the listen would be a web server side directive. so remove all listen instances that you have then site 1: <VirtualHost aa.bb.cc.dd:80> site 2: <VirtualHost ww.xx.yy.zz:80> –  PaulM May 24 '11 at 14:27
    
@PaulM - The VirtualHosts are already in place, but the IP is still bound to port 80 by the overriding Listen xx.xx.xx.xx 80 line. If I remove all listen directives, my sites crash. Any ideas? –  Christopher May 25 '11 at 13:25
    
Take a look at this and see if it helps you out: httpd.apache.org/docs/2.0/vhosts/examples.html –  PaulM May 25 '11 at 13:39
1  
You have a NameVirtualHost in the http.conf. is that needed? I would really put everything in turbopanel.conf. Also take off the Listen 80 in httpd.conf as that binds to all ips to listen on 80. Then in turbopanel.conf i would do listen xxx.xxx.xxx.xxx:80 on the ips you want to bind on port 80. –  PaulM May 25 '11 at 14:18

Usually this error message is either due to entering the wrong IP address or due to port 80 already being in use on the specified IP. Try temporarily changing the port to 81 (or a similar unused number) and see if that works. If it does it means something else is listening on port 80 on one or both of those IPs. netstat should list all the services listening on all addresses.

share|improve this answer
    
@Uesep - I tried changing it port 81 but it still would not restart. Any other ideas? –  Christopher May 25 '11 at 13:26
    
nestat -nlp is usually a good combination to see that. –  ℝaphink May 25 '11 at 14:31

Do you see both ips if you do a

ifconfig -a
share|improve this answer
    
Yes. I see ...inet addr:[MY IP1]......inet addr:[MY IP2]... –  Christopher May 24 '11 at 12:44

The SSL would block the Apache to Listen on the same port.

Try semanage port -l |grep http_t you would get the available listening ports, so that you can choose another port and put virtual host to listen on that.

share|improve this answer

On ubuntu 12.04 you had to add the IP there (httpd.conf is empty) to

NameVirtualHost xx.xx.xx.xx:80 (if you have more than one domain on website)
Listen xx.xx.xx.xx:80

share|improve this answer

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.