Why am I receiving "cannot define multiple Listeners on the same IP:port" error?
Hello,
I'm receiving an error "cannot define multiple Listeners on the same IP:port". Im seeing online that "This error would usually occur when your virtualhost configuration has two different services configured to listen on a single port, causing conflict over that port. "
I've used this in old image for https, I made it listen to port 80 and port 443 for ssl. It was working well in my previous image. In this new image, I installed everything i needed to install unless the config for apache is different .
Hers is my virtual conf file
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin ###@###.###
#DocumentRoot /var/www/example.com/publichtml DocumentRoot /home/application/example.com/publichtml/public
ServerName example.com
ServerAlias example.com
DirectoryIndex index.html index.php
# Available loglevels: trace8, …, trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHELOGDIR}/error.log
#ErrorLog /home/application/example.com/error/error.log
#CustomLog /home/application/example.com/access/access.log combined
CustomLog ${APACHELOGDIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<'/VirtualHost>
<VirtualHost *:80>
ServerAdmin ###@###.###
#DocumentRoot /home/application/support.example.com/publichtml DocumentRoot /home/application/support.example.com/publichtml/upload
ServerName support.example.com
ServerAlias www.support.example.com
DirectoryIndex index.html index.php
CustomLog ${APACHELOGDIR}/access.log combined
<'/VirtualHost>Listen 443
<VirtualHost _default_:443>
DocumentRoot /home/application/example.com/publichtml/public ServerName example.com ServerAlias example.com DirectoryIndex index.html index.php SSLEngine on #SSLCertificateFile "/ssl/yourdomainname.crt"
'#SSLCertificateKeyFile "/ssl/yourprivate_key.key"'
'#SSLCACertificateFile "/ssl/bundle.crt"'
SSLCertificateFile /home/ssl2/example.cert
SSLCertificateKeyFile /home/csr/example.key
SSLCertificateChainFile /home/ssl2/example.ca-bundle
<'/VirtualHost>
'#vim: syntax=apache ts=4 sw=4 sts=4 sr noet'
1 Reply
Hello,
I believe that the issue that you're experiencing here may be caused by the line
Listen 443
In your VirtualHost file.
I'm running Ubuntu 16.04 and when I add the lines either Listen 80 or Listen 443 to my VirtualHost file I receive the error:
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
I believe this is cause by a conflict with your /etc/apache2/ports.conf file. There is a line in this file by default:
<IfModule ssl_module>
Listen 443
</IfModule>
that should already has your server listening for requests on 443 because you have an ssl_module running.
I hope this clarifies your situation a bit and you are able to get your web server functioning the way that you intend.