Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like an Apache Web Server I have installed at home to listen on port 80 and port 8080.

I've added Listen 8080 to httpd.conf and restarted the Apache services but the server doesn't seem to be listening on 8080. Punching in http://localhost:8080 times out and doesn't display my index.html but http://localhost will display my index.html.

How do I make it listen to 80 and 8080?

share|improve this question
    
Why do you think it's not listening on port 8080? It might also be useful to post snippets of your configuration. –  David Z Jun 18 '09 at 15:12
1  
Did you restart Apache after editing the http.conf? –  Dana the Sane Jun 18 '09 at 15:41
    
@David I've updated my question to show why I think it's not listening on 8080. Don't have access to httpd.conf right now. @Dana - yes. –  Owen Jun 18 '09 at 16:19

6 Answers 6

up vote 20 down vote accepted

A standard Debian install of apache will have the following fragment of configuration:

Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

This is telling apache to listen on port 80 and to listen to port 443 if mod_ssl is configured. In your case you'd want:

Listen 80
Listen 8080

You need to make sure you run a restart, not a reload operation on apache for it to pay any attention to new Listen directives. The safest thing to do is to stop apache, make sure it is dead and start it again.

If this configuration does not work, check the log files for any error messages. You could use "netstat -lep --tcp" to see if there is anything listening on port 8080. Finally, if everything else doesn't work, try running apache under strace to see if it's trying to bind to that port and failing, but not logging the problem.

share|improve this answer
    
Great answer (you beat me to it nearly verbatim). –  msanford Jun 18 '09 at 15:15

These answers are great, but they leave out the possibility that Owen has actually done this already ("I've added Listen 8080") may mean exactly what it sounds like (i.e., what David has suggested).

If you have already done this and still find it not working, make sure that you have correctly configured your directives for each subdomain you may have, including the default one (if it's been configured manually to listen to :80 right after the name).

You probably have a directive like this:

<VirtualHost *:80>
 ServerName michaelsanford.com
 etc…
</VirtualHost>

You need to change that to <VirtualHost *:8080> or <VirtualHost *:*>.

share|improve this answer
    
I suspect this is my problem. I think do have a <VirtualHost *:80> directive. I'll have to check this. –  Owen Jun 18 '09 at 16:22
1  
If you don't have a virtual host, you'll be served content from the global DocumentRoot, which will probably either give you a standard index.html, a directory index page, a 404 or a 403 error. It wouldn't timeout. –  David Pashley Jun 18 '09 at 18:33
1  
Sounds like you have a firewall in place that's dropping packets silently. –  msanford Jun 19 '09 at 11:31
    
As it turns out, it was a firewall issue. –  Owen Jun 22 '09 at 10:41

Step 1

#vi httpd.conf
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

httpd(apache) to listen on port 80 and to listen to port 443 if mod_ssl is configured.

Listen 80
Listen 8080

Step 2

#su - service httpd restart

Step 3

$ netstat -lntp

(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)

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:111                 0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:47027               0.0.0.0:*                   LISTEN      -                   
tcp        0      0 192.168.1.1:80              0.0.0.0:*                   LISTEN      -                   
tcp        0      0 192.168.1.1:8080            0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      -                   
tcp        0      0 ::ffff:127.0.0.1:45100      :::*                        LISTEN      3149/java           
tcp        0      0 :::111                      :::*                        LISTEN      -                   
tcp        0      0 :::80                       :::*                        LISTEN      -                   
tcp        0      0 :::57173                    :::*                        LISTEN      3149/java           
tcp        0      0 :::18197                    :::*                        LISTEN      3149/java           
tcp        0      0 :::22                       :::*                        LISTEN      -                   
tcp        0      0 ::1:631                     :::*                        LISTEN      -                   
tcp        0      0 :::40832                    :::*                        LISTEN      3149/java           
tcp        0      0 ::ffff:127.0.0.1:6880       :::*                        LISTEN      3149/java       
share|improve this answer

You may also want to check to see if you have SELinux enabled. The default SELinux configuration may not allow you to run Apache on non-standard ports. Here's a site that shows you if you are running SELinux and how to disable it, if you don't want or use its features. http://www.crypt.gen.nz/selinux/disable_selinux.html

share|improve this answer
    
Or you could leave SELinux on, if you are on a modern SELinux system see how the ports are labeled with a semanage port -l. see danwalsh.livejournal.com/9275.html which is titled "I want my apache daemon to listen on a different port but SELinux is preventing it, What do I do?" –  rev Jul 29 '09 at 21:49

You may need to configure a site a port 8080 for this to work. Read through the documentation for Apache Virtual Hosts. Each 'site' can be set up to accept connections on specific ports (and ip's, etc). Does you have a virtual host in your http.conf that is only configured for port 80?

Also, you can confirm that the server is listening on 8080 using netstat -nlp and looking for an entry on that port.

share|improve this answer
1  
No, this isn't right. If you want apache to listen on a port, you need to use the Listen directive. –  David Pashley Jun 18 '09 at 15:06
    
1  
Well, it might be somewhat right - many people create vhosts like <VirtualHost *:80>, and in that case you would need to change it to <VirtualHost *:*> or create another vhost for port 8080. (Of course, the Listen directive is also required) –  David Z Jun 18 '09 at 15:11
    
@David Pashley, The author stated that the Listen directive had already been added. –  Dana the Sane Jun 18 '09 at 15:27

Assuming linux run netstat -lntp as root as you can see if apache is listening on 8080 or not. This will help you identify if the problem is apache not listening or if there are factors external (e.g. firewall, selinux etc) to apache making the connection time out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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