Apache runs locally but can't be accessed from other machine

17,130

Check where Apache is listening:

$ sudo netstat -nlp | grep apache
tcp        0      0 127.0.0.1:80            0.0.0.0:*               LISTEN    4720/apache2    
                    ^^^^^^^^^

If you see 127.0.0.1 as above, your Apache is only listening on the loopback interface, and other machines won't be able to connect to it. Look for a Listen directive in your Apache config, which will look something like

Listen 127.0.0.1:80

If you remove the 127.0.0.1 (so you just have Listen 80) and restart Apache, it should then be listening on all available addresses.

Share:
17,130

Related videos on Youtube

Tensigh
Author by

Tensigh

Updated on September 18, 2022

Comments

  • Tensigh
    Tensigh over 1 year

    I'm running Apache 2.2.3 in a VM for a test environment on CentOS 5. Apache is running and responding to requests on the VM itself. If I run "lynx localhost" on the VM I do get my test page.

    When I try to access Apache from my actual PC I get nothing. SSH works to the VM but nothing with Apache. I set up iptables on the VM to be open to anything but HTTP requests from my PC still return nothing (I get timeouts when I telnet over port 80 to the VM and my browser just says "cannot open page on 172.16.x.y").

    What else should I check?

    • Petkaux
      Petkaux about 10 years
      What is your Network Setting in Virtualbox? Is it Bridged?
  • Tensigh
    Tensigh about 10 years
    Thanks, I have tried that. In netstat it shows it's listening on 0.0.0.0:80
  • Tensigh
    Tensigh about 10 years
    I tried to lynx on its IP address (not localhost) and it did successfully display the test page. I suspect you're right because SSH to this host DOES work.
  • davidgo
    davidgo about 10 years
    That means you have a networking problem between your VM and the world. Try debugging that. Unfortunately you have not provided details sufficient to point you in the correct direction, but it may well have to do with the VM host / Dom0 doing NAT rather then bridging. This is most likely the case if you can ping out from inside the VM
  • Tensigh
    Tensigh about 10 years
    the problem isn't networking if SSH and ping works but Apache doesn't. I did provide a good amount of details; maybe you could offer more helpful advice before editorializing.
  • davidgo
    davidgo about 10 years
    I'm only a Linux system administrator (for ISP's and web providers) of 20 years. You didn't specify the VM architecture, let alone mtr results, route tables or firewall rules. I wish you luck solving your problem.
  • Tensigh
    Tensigh about 10 years
    I'm sorry if I sounded sarcastic. It was a long day! I did actually state that I opened IP tables to allow anything, but I digress. To be honest, I don't always know what details are relevant - sometimes I put in too much detail and I get chided, other times I don't put in enough. Thanks for your help.