3

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.

2

You only need to bind 1 IP address to apache.

Listen [myIP1]:80

Thats all you need.

9
  • I have two IPs that I use for different sites. It is the third IP I need unbound from Apache for Node.js – Kit 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? – Kit 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
5

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.

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

Do you see both ips if you do a

ifconfig -a
1
  • Yes. I see ...inet addr:[MY IP1]......inet addr:[MY IP2]... – Kit May 24 '11 at 12:44
-1

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.

-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.