Sometimes we want Apache to listen on a port other than the default 80. To achieve this on a Fedora box, one needs to modify its configuration file /etc/httpd/conf/httpd.conf. Change the port number on the line 'Listen 80' to the number you like. If virtual hosts are used, change the related port number as well, eg. NameVirtualHost *:8000. However, when you restart Apache after configuration changes, you may encounter errors like the following, even if you are root:

Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:8000 (13)Permission denied: make_sock: could not bind to address no listening sockets available, shutting down Unable to open logs [FAILED]

This is due to the SELinux policy which prevents Apache from binding to the port you've selected. You can use this shell command to check whether SELinux is in enforcing mode or permissive mode:

cat /selinux/enforce

Output 1 indicates it's in enforcing mode and 0 permissive mode. To resolve this, you can do either of the following:

1) Switch SELinux to permissive mode You can do so with the following shell command:

echo 0 > /selinux/enforce or setenforce 0

However, this is not recommended due to security concerns.

2) Use a port that Apache can currently bind to Try the command:

semanage port -l | grep http

This would output something like the following:

http_cache_port_t              tcp      3128, 8080, 8118, 11211, 10001-10010
http_cache_port_t              udp      3130, 11211
http_port_t                    tcp      80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t            tcp      5988
pegasus_https_port_t           tcp      5989

The list of http_port_t shows that Apache can bind to ports 80, 443, 488, 8008, 8009, 8443. So use a port in this list such as 8008.

3) Add a new port to the http_port_t list You can use the following shell command to add a new port you want to use, say 90

semanage port -a -t http_port_t -p tcp 90

After these changes, restart Apache:

service httpd restart

The previous error should be gone.

Read Next

Mysql remote connection

03 February, 2010|2 min
Get in touch and let’s get started.

We are a full service digital consultancy with experience and capacity to meet the needs of even the largest most complex of organizations in the world. Our services portfolio enables us to offer clients the best of experiences when working with our teams so as to make sure we keep the focus on their needs, customers and delivering tangible value to the business. End to end services; endless ideas. 

Three easy ways to get in touch. Complete the form to request a consultation, email us your inquiry, specs and/or RFP to OR call one of our many, global office locations and tell us how we can help.