Configure HTTPD To Listen on Multiple Ports

How do I configure Apache HTTPD to listen on multiple ports under RHEL / Fedora / CentOS Linux Server?

Multiple ports can be configured via Listen directive under Apache web server. By default httpd listens on TCP port 80.

How to configure httpd to listen multiple ports?

Open configure file /etc/httpd/conf/httpd.conf and modify the Listen directive tells the server to accept incoming requests on the specified port. Multiple Listen directives may be used to specify a number of ports to listen to.
# vi /etc/httpd/conf/httpd.conf
Find line that read as follows:
Listen 80
Force httpd to listen to port 81:
Listen 81
Force httpd to listen on both port 80 and 81:
Listen 80
Listen 81

Save and close the file. Restart httpd:
# /etc/init.d/httpd restart

A note about SELinux

If you are using SELinux, make sure port 81 is configured and not blocked by SELinux. By default SELinux only allows port number 80 and 443 for httpd service. To display current port contexts, enter:
# semanage port -l | grep http
# semanage port -l | grep -w '^http_port_t'

Sample outputs:

http_port_t                    tcp      80, 443, 488, 8008, 8009, 8443

To add port 81 to port contexts, enter:
# semanage port -a -t http_port_t -p tcp 81
You can verify new settings, enter:
# semanage port -l | grep http_port_t
Sample outputs:

http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443

Finally, reload or restart the HTTPD server, enter:
# /sbin/service httpd reload

Page last updated at 5:57 AM, April 21, 2012.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Tanweer Mar 18, 2009 @ 0:13

    so what difference it makes? both port requires root privilege, how can we configure it as a non-root user.
    say i want to listen it to port 8888 and a non-root user wants to start stop apache?

  • Nesrine Jun 8, 2011 @ 13:33

    After adding Listen 8000 to /etc/httpd/conf/httpd.conf
    and restart httpd service httpd restart
    I had this error

    Démarrage de httpd :(98)Address already in use: make_sock: could not bind to address
    no listening sockets available, shutting down
    Unable to open logs

    can someone help me please.

  • Dave Sep 29, 2012 @ 14:31

    For me selinux is disabled already, but I’m still getting this error.

    I want to listen for port 80 on just a subset of IP’s ( thru so I set up my Listen as:

    I then added, on the end a Listen 8000

    Nedless to say, the whole thing failed, and it’s not immediately obvious why from the limited documentation publicly available. Can anyone help please?


  • steve Feb 7, 2013 @ 19:59

    if you dont have semanage install

    yum -y install policycoreutils-python

  • Sturdy Sep 24, 2014 @ 7:36

    How can we give a range of ports in httpd.conf

    For eg.

    instead of
    Listen 31
    Listen 32
    Listen 33
    Listen 34
    Listen 35

    i would like to have

    Listen 31-35

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum