Results 1 to 16 of 16
  1. #1
    Join Date
    May 2001
    Location
    Montreal, Quebec
    Posts
    589

    Apache on a single ip

    Hi,
    I've been trying for some time now to bind apache to only one ip. I added the folowing line to my httpd.conf:

    Listen xxx.xxx.xxx.xxx:80

    Where xxx.xxx.xxx.xxx is the ip I want to bind Apache to but whenever there is Listen directive in the httpd.conf, Apache won't start and gives no error. I know it doesn't start because doing "ps -aux|grep" httpd returns nothing.

    The server OS is Fedora with CPanel.

    Is this a CPanel bug or what ?

    Thank you for your help.

  2. #2
    Join Date
    Apr 2003
    Location
    Los Angeles, CA
    Posts
    800
    Best thing to do would be to check the error log why apache won't start. It would be in the main error log (not a virtual host) so look for the ErrorLog directive in your httpd.conf file and see what file apache uses. Then look at the end and it usually says clearly why the startup failed.

  3. #3
    Join Date
    Mar 2004
    Posts
    66
    doing "ps -aux|grep" httpd returns nothing.

    The server OS is Fedora with CPanel.
    on fedora the command to check if httpd is running is

    service httpd status

  4. #4
    Join Date
    May 2001
    Location
    Montreal, Quebec
    Posts
    589
    After some investigation, the error in the logs is:

    [Tue Mar 30 09:42:27 2004] [crit] (98)Address already in use: make_sock: could not bind to address xxx.xxx.xxx.xxx port 80

    However, the port is not in use and if I don't use the Listen directive, Apache is able to listen to that ip/port.

  5. #5
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    Hi, did you find the solution to this? I'm having the same problem.

    Regards!

  6. #6
    Join Date
    May 2001
    Location
    Montreal, Quebec
    Posts
    589
    I did but this was a long time ago, I don't remember the fix.

  7. #7
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    no problem, I'll figure it out.

    Thanks!

  8. #8
    Did you try a reboot to ensure nothing else is binding to the socket?
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support Web Hosting Reseller Hosting Cloud/VPS Plans Dedicated Servers

  9. #9
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    Nop, I haven't tried a reboot. I always let that as the last resource.

    How could I check the ports and IP's being used? I guess is with "netstats" but I'm not sure what to look (or don't look) for in the list.

    Regards!

  10. #10
    netstat -luntp

    This should also give you a PID which you can try killing the process with...
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support Web Hosting Reseller Hosting Cloud/VPS Plans Dedicated Servers

  11. #11
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    Thanks , I run the command with Apache running and saw:

    0.0.0.0:80 for httpd

    I guess 0.0.0.0 means "all IP addresses" because when using "Listen 80" it's like saying "listen in all IP addresses".

    I stopped Apache, did netstat -luntp again and didn't see any application using port 80.

    I tried restarting Apache then and I keep getting the error:

    Code:
    [crit] (98)Address already in use: make_sock: could not bind to address x.x.x.x port 80
    Any other ideas?

    Thanks

  12. #12
    netstat -luntp shows any applications binding to a port, it does not diplay port numbers, but rather the PID of the process running. Can you paste the output here?
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support Web Hosting Reseller Hosting Cloud/VPS Plans Dedicated Servers

  13. #13
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    Yep, here it is with Apache running with the default "Listen 80":

    Code:
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
    tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:1                   0.0.0.0:*                   LISTEN      5192/portsentry     
    tcp        0      0 0.0.0.0:2082                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 0.0.0.0:1666                0.0.0.0:*                   LISTEN      30964/r0nin         
    tcp        0      0 0.0.0.0:2083                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:2084                0.0.0.0:*                   LISTEN      15993/entropychat   
    tcp        0      0 127.0.0.1:8005              0.0.0.0:*                   LISTEN      5304/java           
    tcp        0      0 0.0.0.0:2086                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 0.0.0.0:2087                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      8081/jsvc.exec      
    tcp        0      0 0.0.0.0:6666                0.0.0.0:*                   LISTEN      15991/startmelange  
    tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      5000/mysqld         
    tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      22763/cppop - accep 
    tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      27489/xinetd        
    tcp        0      0 0.0.0.0:2095                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN      11363/spamd.pid --m 
    tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      5192/portsentry     
    tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      15407/httpd         
    tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      8081/jsvc.exec      
    tcp        0      0 0.0.0.0:44464               0.0.0.0:*                   LISTEN      13924/44464         
    tcp        0      0 0.0.0.0:2096                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:465                 0.0.0.0:*                   LISTEN      11269/exim          
    tcp        0      0 IP1:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP2:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP3:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP4:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP5:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 127.0.0.1:53                0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      18373/proftpd: (acc 
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2227/sshd           
    tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      22106/cupsd         
    tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      11263/exim          
    tcp        0      0 127.0.0.1:953               0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      15407/httpd         
    udp        0      0 IP1:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP2:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP3:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP4:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP5:53         0.0.0.0:*                           13447/named         
    udp        0      0 127.0.0.1:53            0.0.0.0:*                           13447/named         
    udp        0      0 0.0.0.0:52980           0.0.0.0:*                           13447/named         
    udp        0      0 0.0.0.0:631             0.0.0.0:*                           22106/cupsd
    And here is when I stop Apache:

    Code:
    # /etc/init.d/httpd stop
    /etc/init.d/httpd stop: httpd stopped
    
    # netstat -luntp        
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
    tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:1                   0.0.0.0:*                   LISTEN      5192/portsentry     
    tcp        0      0 0.0.0.0:2082                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 0.0.0.0:1666                0.0.0.0:*                   LISTEN      30964/r0nin         
    tcp        0      0 0.0.0.0:2083                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:2084                0.0.0.0:*                   LISTEN      15993/entropychat   
    tcp        0      0 127.0.0.1:8005              0.0.0.0:*                   LISTEN      5304/java           
    tcp        0      0 0.0.0.0:2086                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 0.0.0.0:2087                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      8081/jsvc.exec      
    tcp        0      0 0.0.0.0:6666                0.0.0.0:*                   LISTEN      15991/startmelange  
    tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      5000/mysqld         
    tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      22763/cppop - accep 
    tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      27489/xinetd        
    tcp        0      0 0.0.0.0:2095                0.0.0.0:*                   LISTEN      22780/cpsrvd - wait 
    tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN      11363/spamd.pid --m 
    tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      5192/portsentry     
    tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      8081/jsvc.exec      
    tcp        0      0 0.0.0.0:44464               0.0.0.0:*                   LISTEN      13924/44464         
    tcp        0      0 0.0.0.0:2096                0.0.0.0:*                   LISTEN      12631/stunnel-4.04l 
    tcp        0      0 0.0.0.0:465                 0.0.0.0:*                   LISTEN      11269/exim          
    tcp        0      0 IP1:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP2:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP3:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP4:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 IP5:53             0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 127.0.0.1:53                0.0.0.0:*                   LISTEN      13447/named         
    tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      18373/proftpd: (acc 
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2227/sshd           
    tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      22106/cupsd         
    tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      11263/exim          
    tcp        0      0 127.0.0.1:953               0.0.0.0:*                   LISTEN      13447/named         
    udp        0      0 IP1:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP2:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP3:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP4:53         0.0.0.0:*                           13447/named         
    udp        0      0 IP5:53         0.0.0.0:*                           13447/named         
    udp        0      0 127.0.0.1:53            0.0.0.0:*                           13447/named         
    udp        0      0 0.0.0.0:52980           0.0.0.0:*                           13447/named         
    udp        0      0 0.0.0.0:631             0.0.0.0:*                           22106/cupsd

  14. #14
    Try:
    kill -9 15407
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support Web Hosting Reseller Hosting Cloud/VPS Plans Dedicated Servers

  15. #15
    Join Date
    Nov 2001
    Location
    Lima, Peru
    Posts
    84
    Genius !!!!!

    I noticed the PID you mentioned was the one for Apache listening to SSL connections, I opened httpd.conf and looked for lines referring to SSL and found this:

    Listen 443

    So, Apache was listening just to the IP's I told him for port 80 requests, but I was listening to all IP's for port 443, that was causing the mess

    Thank you very much, I really appreciate your help and kind advice.

    Have a great day!

  16. #16
    Hello,

    The error can also caused due to the below explained reason. The server will need to be restarted to free up the ports. The issue might be that php has gone defunct under the maximums user and has caused that apache and php process to freeze up, and its impossible to kill it to free the port up since as it does not respond to any comands or kill lines. I have faced the same situation before and a reboot solved the issue that time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •