Apache won’t listen on specified port

Posted on

Apache won’t listen on specified port – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, apache-2.2, ssl, port, httpd.

I’ve read the Apache documentation on ‘port binding’ and on ‘virtual hosts’ but have come no closer to a solution. I also scoured serverfault for answers but all point to the same solution: ‘add LISTEN [port number] to your httpd.conf file and restart Apache’. This does not work.

What I am trying to do: make Apache listen to secure connections on port 510 and 443.
What is happening: only port 443 works, both secure and unsecure requests on port 510 fail.

How I have attempted to do this (in my httpd.conf file):

Listen 80
Listen 443
Listen 510

NameVirtualHost *:510

<VirtualHost *:510>
    ServerName samplesite.com
    ServerAlias *.samplesite.com
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "conf/ssl/_.samplesite.com/_.samplesite.com.crt"
    SSLCertificateKeyFile "conf/ssl/_.samplesite.com/_.samplesite.com.key"
    SSLCertificateChainFile "conf/ssl/_.samplesite.com/gd_bundle.crt"
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    AllowEncodedSlashes On
</VirtualHost>

<VirtualHost *:443>
    ServerName samplesite.com
    ServerAlias *.samplesite.com
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "conf/ssl/_.samplesite.com/_.samplesite.com.crt"
    SSLCertificateKeyFile "conf/ssl/_.samplesite.com/_.samplesite.com.key"
    SSLCertificateChainFile "conf/ssl/_.samplesite.com/gd_bundle.crt"
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    AllowEncodedSlashes On
</VirtualHost>

Any help would be greatly appreciated.

Solution :

There could only two reasons I can think of right now.

  1. You have Selinux enabled on your machine, which is interfering with your settings. To test that, check the output of this command

    # getsebool

If this says something like this:

getsebool:  SELinux is enabled

That simply means that Selinux is enabled. To temporary disable it, use this command:

 # setenforce 0

This will disable your Selinux temporary. Try your apache new port after that.

  1. You have firewall enabled on your machine. Not sure which distro you are using, but try to check your firewall on your machine and allow access to 510 port if you have it enabled.

  2. Also, check the output of the command netstat -npl | grep 510 and see whether after restarting apache, is it really opening a port or not.

I see that you have enabled NameBased Virtual Hosting for additional SSL Port 510.

NameVirtualHost *:510

SSL is a different entity and does not understand HTTP Host Headers on which Apache Name Based Virtual Host is based on.

Your best bet is to remove “NameVirtualHost *:510”

Leave a Reply

Your email address will not be published.