How to configure HTTPD to listen on a port other than 80 or 443

Home > Search > How-to

The hostname and port that the web server is using will be listed in the /etc/httpd/conf/httpd.conf file. In this example, the hostname is and the port is 80. In this example, navigating to will cause the web server to server it's default document.



If you need to configure HTTPD to listen for connections on a different port of than 80, in the /etc/httpd/conf/httpd.conf file, ensure you have the following configuration. In this example, port 12345 is used. Use your preferred IP address and port number. Also ensure the port number is not already associated with a service in the /etc/services file.



Add the port number to the http_port_t context.

[root@server1 ~]# semanage port -a -t http_port_t -p tcp 12345


Ensure the port number is in the http_port_t context.

[root@server1 ~]# semanage port -l | grep -w http_port_t
http_port_t                    tcp      12345, 80, 443, 488, 8008, 8009, 8443


Restart HTTPD, and ensure HTTPD is active and running.

[root@server1 ~]# systemctl restart httpd
[root@server1 ~]# systemctl status httpd


Use the apachectl configtest command can be used to verify the configuaration of HTTPD is OK.

[root@server1 ~]# apachectl configtest
. . .
Syntax OK


Update iptables to allow connections on port 12345.

Restart iptables, and ensure iptables is active and running.

[root@server1 ~]# systemctl restart iptables
[root@server1 ~]# systemctl status iptables


From a PC in the same subnet as the HTTPD web server, ensure you get the default HTTPD page when navigating to


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.