3

I have a website served by apache. It works with IPv4 but not with IPv6. I have a 500 error.

Here is my ports.conf file :

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80
NameVirtualHost *:80

<IfModule ssl_module>
        Listen 443
</IfModule>

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

And my VHost :

<VirtualHost *:80 [::]:80>
DocumentRoot "/var/www/html/mysite.ca/www.mysite.ca"
ServerName mysite.ca
<Directory "/var/www/html/mysite.ca/www.mysite.ca">
allow from all
Options +Indexes
</Directory>
ServerAlias www.mysite.ca
</VirtualHost>

When I do netstat-tlnpt, I have this :

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3577/master
tcp        0      0 0.0.0.0:453             0.0.0.0:*               LISTEN      4484/perl
tcp        0      0 0.0.0.0:360             0.0.0.0:*               LISTEN      3254/sshd
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      3307/mysqld
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      2923/vsftpd
tcp6       0      0 ::1:25                  :::*                    LISTEN      3577/master
tcp6       0      0 :::443                  :::*                    LISTEN      7240/apache2
tcp6       0      0 :::360                  :::*                    LISTEN      3254/sshd
tcp6       0      0 :::80                   :::*                    LISTEN      7240/apache2

It seems apache is already listening for IPv6 address.

I tried to add :

Listen [::]:80
Listen [::]:443

To my port file but I have this result when I restart apache :

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

I tried to change wildcars by static address and I have the same issue.

I have other websites that works with IPv6 on the same server. This is the only that doesn't work.

What can I do ?

10
  • 1
    What's in the apache logs?
    – sysfiend
    Dec 7, 2016 at 17:38
  • 1
    Eh? www.mysite.ca doesn't even have an IPv6 address. You need to fix that first. Dec 7, 2016 at 17:52
  • @MichaelHampton mysite.ca is not the real name
    – Dougui
    Dec 7, 2016 at 17:53
  • @Alex There is nothing in logs
    – Dougui
    Dec 7, 2016 at 17:54
  • Still thinking about it but, first of all, you don't need to add Listen [::]:80 Listen [::]:443. Listen <port> already works for both IPv4 and IPv6
    – sysfiend
    Dec 7, 2016 at 18:04

3 Answers 3

7
+100

Make sure apache2 is fully being shutdown. Possibly whatever is managing services doesn't know about a copy manually launched in the background. (run netstat when it should be stopped and make sure nothing's still listening)

Depending on your apache version, you may not need NameVirtualHost either. See https://httpd.apache.org/docs/current/upgrading.html

If you're getting a 500 error, then something is definitely listening on the port and responding. This should be logged in your error.log. If not, you may need to adjust logging options to include it. I don't see anything indicating whether you're running apache2.2 or 2.4 and the logging configuration is different between the two.

EDIT: See this page about LogLevel https://httpd.apache.org/docs/2.4/mod/core.html#loglevel

4

Make sure you have Listen once per port per IP per complete config per server, maybe comment out the ones you're aware of until it starts without complaining and see if it's still starting on port 80/443

for ipv6 and ipv4, you only need

listen 80
listen 443 https

find /etc/httpd/ | xargs grep -sniH "listen"

1

I see this in your netstat output:

tcp6 0 0 :::443 :::* LISTEN 3254/sshd

That means you have a ssh process listening on your port 443 in IPv6 and indeed Apache cant bind to that port:

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

2
  • I will check it but I have the problem on the port 80.
    – Dougui
    Dec 9, 2016 at 18:02
  • Sorry, this was a copy/paste error. I correct it.
    – Dougui
    Dec 9, 2016 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .