NGINX [1.25.1][warn] the Listen HTTP2 Directive Is Deprecated, Use the HTTP2 Directive Instead

Published in

on

Just updated a server which upgraded nginx to 1.25.1 and while checking the status of nginx web server the following message is popping up for my all server directives.

It says: The “listen…http2” directive is deprecated, use the “http2” directive instead.

nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead.

The solution is very easy. It says the flag “http2” we use in listen directive has been changed to a dedicated directive, so move the flag to directive with yes flag.

It will give us control of yes and no flag.

Just convert the formatting from this …

server {
    listen 127.0.0.1:443 ssl http2;
    ... other configs ...
}

… to this: (the new format for nginx version >= 1.25.1)

server {
    listen 127.0.0.1:443 ssl;
    http2 on;
    ... other configs ...
}

Now test and restart the nginx web server.

sudo nginx -t
sudo systemctl restart nginx

If you are using some template for server blocks, just update this everywhere.

Leave a Reply

Your email address will not be published. Required fields are marked *