7

I am confused why Apache is not responding on port 80 ...

$ wget http://localhost:80  
--2014-05-06 15:32:44--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.

... but instead on post 8080 ...

$ wget http://localhost:8080
--2014-05-06 15:32:38--  http://localhost:8080/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 177 [text/html]
Saving to: ‘index.html’

100%[=================================================>] 177 --.-K/s   in 0s

2014-05-06 15:32:38 (16,4 MB/s) - ‘index.html’ saved [177/177]

Not too much too see in the output of apache2ctl:

$ apache2ctl -t -D DUMP_VHOSTS
VirtualHost configuration:
*:80 is a NameVirtualHost
   default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)

However, netstat confirms the port:

$ sudo netstat -anp | grep :8080
tcp6       0      0 :::8080        :::*       LISTEN      5353/apache2

As asked by Joel here is the ports.conf:

$ sudo cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default

Listen 8080

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# NameVirtualHost *:8800
Listen 8800
  • What's the value of the Listen directive in the config file? – Bratchley May 6 '14 at 13:47
  • @JoelDavis Strange. How comes? I cannot remember that I configured the port manually (this is a freshly installed Ubuntu machine). Please convert your comment to an answer if this is the final solution. – JJD May 6 '14 at 13:58
1

What's the value of the Listen directive in the config file in /etc/apache2/ports.conf?

5

Why is Apache running on port 8080 instead on port 80?

The usual reason why apache is often configured to listen on that port is that a process need to be run under the root account or to be granted specific privileges to be able to listen on TCP ports lower than 1024 and that includes of course port 80.

Using an higher, unprivileged port number allows to run apache under a regular account without any specific configuration.

8080 is an easy to remember replacement for 80.

  • Is there any point within the installation of Apache2 where the user can decide which account is used to run the service? – JJD May 6 '14 at 14:36
  • 2
    @jillagre Apache httpd doesn't have this limitation. It's supposed to always start as root and then drop down to the account specified by the User directive on its own. Tomcat has this limitation (having to run as root or a non-80 port) because it's an application server as so such things aren't its primary focus. – Bratchley May 6 '14 at 15:48
  • 1
    at JJD As far as I know, not with ubuntu apache2 package. @JoelDavis Your are right 8080 is the default Tomcat port and packaged apache2 are designed to start as root. However, should a non root user want to install apache from source or should apache2 be installed and started as non root for some other reason, the point is still valid. Apache doesn't demand to be run as root. – jlliagre May 6 '14 at 16:44

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.