1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
6 <meta name="generator" content="HTML Tidy, see www.w3.org" />
8 <title>Setting which addresses and ports Apache uses</title>
10 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
12 <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
13 vlink="#000080" alink="#FF0000">
14 <!--#include virtual="header.html" -->
16 <h1 align="center">Setting which addresses and ports Apache
19 <p>When Apache starts, it connects to some port and address on
20 the local machine and waits for incoming requests. By default,
21 it listens to all addresses on the machine. However, it needs to
22 be told to listen to specific ports, or to listen to only selected
23 addresses, or a combination. This is often combined with the
24 Virtual Host feature which determines how Apache responds to
25 different IP addresses, hostnames and ports.</p>
27 <p>The <code>Listen</code> directive tells the server to accept
28 incoming requests only on the specified port or
29 address-and-port combinations. If only a port number is
30 specified in the <code>Listen</code> directive, the server
31 listens to the given port on all interfaces. If an IP address
32 is given as well as a port, the server will listen on the given
33 port and interface. Multiple Listen directives may be used to
34 specify a number of addresses and ports to listen to. The
35 server will respond to requests from any of the listed
36 addresses and ports.</p>
38 <p>For example, to make the server accept connections on both
39 port 80 and port 8000, use:</p>
44 To make the server accept connections on two specified
45 interfaces and port numbers, use
48 Listen 192.170.2.5:8000
50 IPv6 addresses must be surrounded in square brackets, as in the
53 Listen [fe80::a00:20ff:fea7:ccea]:80
56 <h2>Special IPv6 considerations</h2>
58 When APR supports IPv6, Apache will create IPv6-capable listening
59 sockets by default (i.e., when no IP address is specified on the
60 Listen directive). In other words, when APR supports IPv6,
68 When APR does not support IPv6,
76 On some platforms, such as NetBSD, binding to the IPv6 wildcard address
77 ("::") does not allow Apache to accept connections on IPv4 interfaces.
78 In this situation, multiple Listen directives are required, as shown
84 Apache does not currently detect this, so the Listen statements must
85 be edited manually by the administrator.
87 <h2>How this works with Virtual Hosts</h2>
89 <p>Listen does not implement Virtual Hosts. It only tells the
90 main server what addresses and ports to listen to. If no
91 <VirtualHost> directives are used, the server will behave
92 the same for all accepted requests. However,
93 <VirtualHost> can be used to specify a different behavior
94 for one or more of the addresses and ports. To implement a
95 VirtualHost, the server must first be told to listen to the
96 address and port to be used. Then a <VirtualHost> section
97 should be created for a specified address and port to set the
98 behavior of this virtual host. Note that if the
99 <VirtualHost> is set for an address and port that the
100 server is not listening to, it cannot be accessed.</p>
103 See also the documentation on <a
104 href="mod/mpm_common.html#listen">Listen directive</a>, <a
105 href="vhosts/">Virtual Hosts</a>, <a
106 href="dns-caveats.html">DNS Issues</a> and <a
107 href="mod/core.html#virtualhost"><VirtualHost>
108 section</a>. <!--#include virtual="footer.html" -->