100

I'm trying to install trac and mod_wsgi over SSL. I tried to manually install it, but that didn't work out so well so I started to follow this: trac-on-ubuntu

I skipped the svn part because I'd like to use git instead. After the first edit of httpd.conf:

WSGIScriptAlias /trac /var/trac/apache/trac.wsgi

<Directory /var/trac/apache>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

I restarted apache only to get this error:

* Restarting web server apache2                                                    

(98)Address already in use: make_sock: could not bind to address [::]:443

                                                                     [ OK ]

Doing these showed nothing.

 netstat -anp | grep 443 
 fuser 443/tcp

Doing this didn't yield anything except the grep command that I ran:

ps -aux | grep httpd

Why is it saying that something else is using the port when there's nothing showing up?

EDIT: You guys are going to laugh at this. I had an extra Listen 443 in ports.conf that shouldn't have been there. Removing that solved this.

sharkfin
  • 3,827
  • 4
  • 23
  • 22
  • Good you found the extra Listen statement. Was going to suggest just that as possible cause until I got to your edit. :-) – Graham Dumpleton Feb 05 '12 at 01:03
  • 3
    You may want to re-write your edit into an answer and accept it. This is the recommended way to mark a question as "solved" and not needing much more support. – hasienda Feb 05 '12 at 22:12
  • 2
    Unfortunately, I have this problem, but an extra "Listen 443" is not the cause... – Cerin Oct 10 '12 at 19:44
  • 1
    I had exactly the same problem. Removed the top most 443 from ports.conf, restarted apache2 and it all worked. – PrestonDocks May 16 '16 at 15:39
  • 8 years later and another individual that doesn't want to mention his name coming across this problem. And of course 8 years later searching for the error message you land on stack overflow. Thats why i just had to ad a message ;) – NME New Media Entertainment Jul 27 '20 at 15:05

13 Answers13

239

You guys are going to laugh at this. I had an extra Listen 443 in ports.conf that shouldn't have been there. Removing that solved this.

sharkfin
  • 3,827
  • 4
  • 23
  • 22
  • 45
    Thanks, mine was in /etc/httpd/conf.d/ssl.conf – Nabil Kadimi Jan 17 '13 at 23:14
  • 15
    I updated apache with YUM, and it created a new ssl.conf file with another listen 443.... – zzarbi Jul 10 '13 at 20:40
  • 4
    Thank you... Some day, I hope for a webserver as widely deployed as apache that isn't a convoluted headache to configure – Mike Pennington Nov 06 '13 at 15:45
  • 4
    In my case, an upgrade of httpd on Centos caused reinstallation of ssl.conf... but we declare Listen 443 in a different config file. Puppet removes ssl.conf... but puppet runs under passenger/httpd. So puppet agent never got the chance to remove the ssl.conf, so there were 2 Listen 443 directives, as described here. – rfay Apr 14 '14 at 16:05
  • Thank you, in /etc/httpd/conf.d/ssl.conf then I remove from ... and apache works fine – Nam Nguyen May 16 '14 at 03:06
  • In my case was a different file location, but in general is the same issue, duplicate Listen 443. You should find any duplicate line "Listen 443" in any apache conf file. To be exact, you should not have "Listen 443" in two or more file. – manuelpgs Jan 02 '17 at 19:05
  • I had the exact same issue with CentOS 7. Nice one :) – meskobalazs Mar 23 '17 at 10:24
  • 1
    /etc/apache2/ports.conf – Hernán Eche Jan 19 '18 at 15:30
  • 1
    I ran certbot, which inserted another 443 entry in my config file. Thanks! – Senica Gonzalez Feb 08 '18 at 17:25
  • I had the same issue on Apache 2.4.7 (Ubuntu 14.04.5), but the same configuration did not give me any trouble on another machine with Apache 2.4.18 (Ubuntu 16.04.4) – UlfR Mar 28 '18 at 07:22
20

Thank you for you answers, on apache 2.4.x versions if have installed ssl_module using yum command, dont want to add the port :443 in httpd.conf (main) file,

To find out the port 443 in configure files,

# grep '443' /etc/httpd/conf.d/*

/etc/httpd/conf.d/ssl.conf:Listen 443 https
/etc/httpd/conf.d/ssl.conf:<VirtualHost _default_:443>
/etc/httpd/conf.d/ssl.conf:#ServerName www.example.com:443

# grep '443' /etc/httpd/conf/httpd.conf 
Listen 443

Just remove the line or command it (Listen 443) from httpd.conf file.

Lakshmikandan
  • 4,301
  • 3
  • 28
  • 37
15

I'm adding another answer to this as I had the same problem and solved it the same way: I had installed SSL on apache2 using a2enmod ssl, which seems to have added an extra configuration in /etc/apache2/ports.conf:

NameVirtualHost *:80
Listen 80

NameVirtualHost *:443
Listen 443

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

I had to comment out the first Listen 443 after the NameVirtualHost *:443 directive:

NameVirtualHost *:443
#Listen 443

But I'm thinking I can as well let it and comment the others. Anyway, thank you for the solution :)

Matthieu
  • 2,736
  • 4
  • 57
  • 87
4

For everyone else who has no duplicate Listen directives and no running processes on the port: check that you don't accidentally include ports.conf twice in apache2.conf (as I did due to a bad merge).

Andreas Gohr
  • 4,617
  • 5
  • 28
  • 45
3

I am using Ubuntu. I just disabled ssl mode of apache2 and it worked for me.

a2dismod ssl

and then restarted apache2.

service apache2 restart
Baran
  • 1,114
  • 1
  • 10
  • 25
3

I use apache version 2.4.27, also have this problem, solved it through modify

the conf/extra/httpdahssl.conf,comment the 18 line content(Listen 443 https),it works fine.

tao.zhang
  • 31
  • 1
2

I made the mistake of incorrectly naming a backup file in the /etc/httpd/conf.d directory. In the README it states that it alphabetically goes through all .conf files.

I had created ssl-<date>.conf (meant to be a backup) and it was loading before ssl.conf. It was binding the :443 port based on the ssl-<date>.conf and failing on the ssl.conf.

Once I renamed the backup file to ssl.conf.<date>, the service started without issue.

As a note, the server I'm on is running RHEL 6

Mike F
  • 21
  • 1
  • Something like this happened to me, so I thought I'd mention it in case it helps someone. I renamed ssl.conf so I could remember that it was set up to use letsencrypt. Later, I allowed what I thought was a minor update to Apache to happen. That update put ssl.conf back in conf.d, creating the conflict in Listen statements. Not sure what to do about this except be vigilant. If I'd stuck with the default ssl.conf filename, the update probably would have clobbered it! – Brian Doherty Aug 19 '17 at 20:10
  • I have done the same thing and Apache couldn't start. I had removed that back up file and it started working. Thank you very much for this answer, you are a life saver. – Umesh Patil Jun 18 '20 at 17:34
  • this is the answer! – Xplore Apr 07 '21 at 12:04
1

I seconded Matthieu answer

I commented #Listen 443 in httpd-ssl file and apache can be started

Because the file already has VirtualHost default:443

1

Let me add one more reason for the error. In httpd.conf I included explicitly

Include etc/apache24/extra/httpd-ssl.conf

while did not notice previous wildcard

Include etc/apache24/extra/*.conf

Grepping 443 will not find this.

Vladimir Botka
  • 58,131
  • 4
  • 32
  • 63
1

I had same issue, was due to multiple copies of ssl.conf In /etc/httpd/conf.d - There should only be one.

Unknown
  • 11
  • 1
  • Sorry to say, but this is a comment, not an answer. If you have more informations about the solution what you have found out about the case, please let us know. – RobertS supports Monica Cellio Dec 06 '19 at 17:30
  • The real explaination is more multiple "Listen 443" present in differents ssl.conf than the differents config files. Removing only the "Listen 443" solve the issue. – Bertrand Cebador Oct 25 '21 at 10:03
0

I have checked and fixed the following and got it resolved -

  1. httpd.conf file at /etc/httpd/conf/
  2. Checked the listening IP and port e.g. 10.12.13.4:80
  3. Removed extra listening port(s)
  4. Restarted the httpd service to take
parakmiakos
  • 2,994
  • 9
  • 29
  • 43
Rajorshe Mistry
  • 41
  • 1
  • 1
  • 9
0

I meet the problem in windows7, phpeclipse, when I start the XAMPP. My solution is :

  • 1.Commented out the \xampp\apache\conf\httpd.conf -> line171 -> #LoadModule ssl_module modules/mod_ssl.so

  • 2.line539 -> #Include conf/extra/httpd-ssl.conf

or you can change the 443 port to another one

Francois Borgies
  • 2,378
  • 31
  • 38
XuLu
  • 79
  • 5
0

In httpd.conf instead:

Listen *:443

you need write Listen 127.0.0.1:443 It works for me.

Ilario Pierbattista
  • 3,175
  • 2
  • 31
  • 41
  • You would only use ``127.0.0.1`` in a listen statement if you wanted to restrict acceptance of connections to the local host loop back interface only. Removal of duplicate ``Listen`` statement as stated by many is the more typical solution. If you had duplicates, on ``*:443``, then changing one to use ``127.0.0.1`` shouldn't really have made a difference as the other ``*:443`` would still try and bind same port on ``127.0.0.1``. – Graham Dumpleton Jun 04 '17 at 20:36