Can't connect to Apache webserver running on Ubuntu 20.04 headless server

5,532

In file /etc/apache2/ports.conf change

Listen 80

to

Listen 0.0.0.0:80

You may get more information about this on unix.stackechange.com.

Note: ISPs typically give dynamic IP address. These IPs change with time and live within multiple layers of switches and hubs. Thus not accessible from other computers. You may need to ask for static IP from your ISP.

Without static IP, you can access this computer from your home/office network only. To access within such network, you can get the IP using ip -4 addr

Moreover, as given by Pavel Šimerda in the unix.stackexchange.com link,

Linux machines typically hide a dualstack IPv4+IPv6 socket behind listening on IPv6 address ::

Share:
5,532

Related videos on Youtube

Sebr
Author by

Sebr

Updated on September 18, 2022

Comments

  • Sebr
    Sebr over 1 year

    I'm setting up NextCloud, but I'm having trouble connecting to my web server. Apache seems to be working until I try and connect to the IP in my browser which just times out or get 100% packet loss if I try to ping it.

    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
         Active: active (running) since Sun 2020-08-02 02:59:09 UTC; 8h ago
           Docs: https://httpd.apache.org/docs/2.4/
        Process: 124731 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
       Main PID: 124754 (apache2)
          Tasks: 6 (limit: 4474)
         Memory: 15.2M
         CGroup: /system.slice/apache2.service
                 ├─124754 /usr/sbin/apache2 -k start
                 ├─124756 /usr/sbin/apache2 -k start
                 ├─124757 /usr/sbin/apache2 -k start
                 ├─124758 /usr/sbin/apache2 -k start
                 ├─124759 /usr/sbin/apache2 -k start
                 └─124760 /usr/sbin/apache2 -k start
    
    Aug 02 02:59:09 verygoodserver systemd[1]: Starting The Apache HTTP Server...
    Aug 02 02:59:09 verygoodserver systemd[1]: Started The Apache HTTP Server.
    

    It's definitely listening on port 80:

    tcp6 0 0 :::80 :::* LISTEN 124754/apache2

    ... and I've added an ufw exception for ports 80 and 443, but that hasn't made any difference either.

    Thanks for your help.

    • turbulence
      turbulence almost 4 years
      Are you sure about it's IP address?
    • turbulence
      turbulence almost 4 years
      Note there are three ::: before 80. Such notation is often used in IPv6. Seems that it is listening on IPv6.
    • turbulence
      turbulence almost 4 years
      tcp6 confirms this.
    • Sebr
      Sebr almost 4 years
      Oh awesome, thanks. Is there a was to change to IPv4? And I used curl http://icanhazip.com to find the IP, if that's still relevant.
  • Sebr
    Sebr almost 4 years
    I edited port.conf but still no luck, but can access from my home network. Might be time to speak to the ISP. Thanks for your help.
  • turbulence
    turbulence almost 4 years
    Also, you need to configure your router for Port Forwarding. i.e. when some request will come to your router from outside, it will forward that request to the computer.
  • Sebr
    Sebr almost 4 years
    Thanks, you've been such a massive help. Can confirm that I needed to to setup the static IP ($5p.m. from my ISP) and setup forward porting. For anyone reading this with a Netcomm router I also needed to change the default port for remote admin to port 88 so that I wouldn't be taken to my router's login page when I vistied my IP (seems like a risky default setting when the default login is admin: admin)
  • turbulence
    turbulence almost 4 years
    Indeed, you have to do all these settings and change the default password as well.