Apache warns that the server certificate does not match the server name
[ssl:warn] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server nameShort answer
Apache is telling you that the ServerName of an SSL virtual host is not one of the names inside the certificate that virtual host loads. It is a warning and Apache still starts, but browsers will reject the site. Fix it by changing ServerName or by issuing a certificate that lists that name.
Fix it fast
1Find out which cause you have
Print the names stored in the certificate the virtual host loads, and compare them with its ServerName line.
openssl x509 -noout -subject -ext subjectAltName -in /path/to/server.crt grep -rn "ServerName\|SSLCertificateFile" /path/to/apache/conf/extra/httpd-ssl.conf2Match what you see, then jump to its fix
- 1
The ServerName in the log line is missing from the certificate's subject and subjectAltNameServerName is not listed in the certificateFix - 2
Only some virtual hosts warn, each with its own name in the log lineSeveral SSL virtual hosts share one certificate fileFix - 3
The name in the log line is not the domain you meant to serveThe virtual host has no ServerName of its ownFix
- 1
What does the error look like?
[ssl:warn] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
Cause 1 of 3
ServerName is not listed in the certificate
1Check
Apache's source compares the virtual host's own ServerName with the certificate names, and logs the warning when none match.
openssl x509 -noout -text -in /path/to/server.crt | grep -A1 "Subject Alternative Name"2Fix
Create a certificate that lists the name you use. The Apache FAQ asks for the server's fully qualified name as the common name. Add the names as subjectAltName too, because current clients check that field.
openssl req -new -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout server.key -out server.crt \
-subj "/CN=www.example.com" \
-addext "subjectAltName=DNS:www.example.com,DNS:example.com"3Verify
Restart Apache and look for the warning in the error log. It should be gone.
openssl x509 -noout -ext subjectAltName -in server.crtConfirmed by httpd.apache.org
Cause 2 of 3
Several SSL virtual hosts share one certificate file
1Check
The check runs for each virtual host and each SSLCertificateFile it loads. A virtual host with a different ServerName that points at the same certificate warns.
grep -n -B2 -A6 "<VirtualHost" /path/to/apache/conf/extra/httpd-ssl.conf2Fix
Give every SSL virtual host its own ServerName and its own certificate, or one certificate that lists all those names (a multi-name or wildcard certificate).
<VirtualHost *:443>
ServerName www.example.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/example.crt"
SSLCertificateKeyFile "conf/ssl.key/example.key"
</VirtualHost>3Verify
Test the config and restart Apache.
httpd -tConfirmed by httpd.apache.org
Cause 3 of 3
The virtual host has no ServerName of its own
1Check
Without ServerName, a virtual host inherits the main server's name or one derived from reverse DNS. The Apache docs call this counter-intuitive and discourage it.
grep -n "ServerName" /path/to/apache/conf/httpd.conf /path/to/apache/conf/extra/*.conf2Fix
Set ServerName explicitly inside each virtual host to the name the certificate holds.
<VirtualHost *:443>
ServerName www.example.com
ServerAlias example.com
</VirtualHost>3Verify
Restart Apache and request the site by that name.
curl -vI https://www.example.com/Confirmed by httpd.apache.org
How do I stop it coming back?
- Set ServerName in every virtual host, HTTP and HTTPS.
- Generate local certificates with the subjectAltName for each name you use, and keep the host entry in sync.
- Keep the certificate file and the ServerName next to each other in one config file, so a rename updates both.
- Read the Apache error log after each restart; this warning is easy to miss because the server still starts.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Servers
Status code 460 on an AWS Application Load Balancer
elb_status_code 460 in ALB access logs
A 460 is generated by the load balancer, not by your app.
3 causes, each with a fixServers
Application Load Balancer returns 504 for requests to EC2 instances
HTTPCode_ELB_504_Count
A 504 from an Application Load Balancer means it could not get an answer from a target in time.
4 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fix