nginx warns that 'ssl on' is deprecated, or serves plain HTTP on 443
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive insteadShort answer
The ssl directive was made obsolete in nginx 1.15.0 and removed in 1.25.1. Delete 'ssl on;' and add the ssl parameter to the listen line instead: listen 443 ssl;. If you delete the line and leave listen 443 without ssl, nginx answers on that port without TLS.
Fix it fast
1Find out which cause you have
Find every place the old directive is used, including included files.
grep -R -n -E "^\s*ssl\s+on" /etc/nginx/2Match what you see, then jump to its fix
- 1
The warning names the file and line of 'ssl on;'. On nginx 1.25.1 or later the directive no longer exists, so the check fails instead of warning.The config still contains the old ssl on directiveFix - 2
nginx -t passes, yet https://example.com fails and the port answers in plain HTTP.ssl on was removed but the listen line has no ssl parameterFix
- 1
What does the error look like?
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive insteadnginx -t fails after an upgrade to 1.25.1 or later, at the line that contains ssl on;
Cause 1 of 2
The config still contains the old ssl on directive
1Check
Look at the server block that holds the line and at its listen directive.
sudo nginx -T 2>&1 | grep -n -E "listen|ssl on"2Fix
Remove 'ssl on;' and put the ssl parameter on the listen directive of the same server block.
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
}3Verify
The syntax test passes without the warning.
sudo nginx -tConfirmed by nginx.org
Cause 2 of 2
ssl on was removed but the listen line has no ssl parameter
1Check
Print the listen directives. TLS is enabled per listening socket, so a bare 'listen 443;' has none.
grep -R -n "listen" /etc/nginx/sites-enabled/2Fix
Add ssl to each listen line that must serve HTTPS. For IPv6, repeat it on the second line.
listen 443 ssl;
listen [::]:443 ssl;3Verify
Reload and check that the handshake works.
sudo nginx -t && sudo systemctl reload nginx
curl -I https://example.comConfirmed by nginx.org
How do I stop it coming back?
- After every nginx upgrade run nginx -t before reloading, and read the warnings, not only the final line.
- Keep one listen line per port and address, each with its own ssl parameter.
- Remove copied snippets from old tutorials that start with ssl on.
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.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
nginx refuses to start: private key does not match the certificate
SSL: error:05800074:x509 certificate routines::key values mismatch
nginx pairs the private key with the first certificate in the ssl_certificate file.
2 causes, each with a fixServers
A Let's Encrypt certificate did not renew with Certbot
Type: connection ... Timeout during connect (likely firewall problem)
Run sudo certbot renew --dry-run and read the Type and Detail lines.
6 causes, each with a fixServers
curl cannot connect to port 80 or 443 on a server running nginx
CURLE_COULDNT_CONNECT (7): Failed to connect() to host or proxy
Exit code 7 means the TCP connection itself failed, before any HTTP happened.
3 causes, each with a fixServers
Django returns a 500 behind Gunicorn and the traceback is nowhere
The traceback shows locally with runserver but not under Gunicorn
With DEBUG set to False, Django's default logging does not print errors to the console.
2 causes, each with a fixServers
Your website on a Google Compute Engine VM times out on port 80
The site works with curl on the VM but not from outside
A timeout, as opposed to a refusal, usually means a firewall dropped the packets.
3 causes, each with a fixServers
Gunicorn rejects a request with "Error parsing headers: limit request headers fields size"
Error parsing headers: 'limit request headers fields'
Gunicorn caps the size of one header field at 8190 bytes and the number of headers at 100 by default.
2 causes, each with a fix