Skip to content

Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR

I have Magento 2.4.4 running on Plesk CentOS Server.

PHP 8.1
PHP FPM Enabled
Varnish on Port 80
Nginx on Port 8080 and 443
Apache on Port 7080 and 7081

Most of the time the website doesn’t load well or even sometimes a blank page. While checking chrome console I keep getting the error message:

Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR

Attached the nginx configuration

# Taken from https://gist.github.com/denji/8359866
# you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that
worker_processes 16; #some last versions calculate it automatically

# number of file descriptors used for nginx
# the limit for the maximum FDs on the server is usually set by the OS.
# if you don't set FD's then OS settings will be used which is by default 2000
worker_rlimit_nofile 4096;

# only log critical errors
error_log /var/log/nginx/error.log crit;
#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    # determines how much clients will be served per worker
    # max clients = worker_connections * worker_processes
    # max clients is also limited by the number of socket connections available on the system (~64k)
    worker_connections 1024;

    # optimized to serve many clients with each thread, essential for linux -- for testing environment
    use epoll;

    # accept as many connections as possible, may flood worker connections if set too low -- for testing environment
    multi_accept on;
}


http {
    # cache informations about FDs, frequently accessed files
    # can boost performance, but you need to test those values
    open_file_cache max=5000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    # to boost I/O on HDD we can disable access logs
    access_log off;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    # copies data between one FD and other from within the kernel
    # faster than read() + write()
    sendfile on;

    # send headers in one piece, it is better than sending them one by one
    tcp_nopush on;

    # don't buffer data sent, good for small data bursts in real time
    tcp_nodelay on;

    # allow the server to close connection on non responding client, this will free up memory
    reset_timedout_connection on;

    # request timed out -- default 60
    client_body_timeout 12;

    # Tips from https://sysopstechnix.com/7-tips-for-nginx-performance-tuning/
    client_body_buffer_size 128k;
    client_header_buffer_size 1k;
    client_max_body_size 10m;
    large_client_header_buffers 10 512k;
    client_header_timeout 12;

    # if client stop responding, free up memory -- default 60
    send_timeout 2;

    # server will close connection after this time -- default 75
    keepalive_timeout 15;

    # number of requests client can make over keep-alive -- for testing environment
    keepalive_requests 100000;

    server_tokens off;

    # security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Cache-Status $upstream_cache_status;
    add_header Referrer-Policy "no-referrer-when-downgrade" always;
    add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    # OCSP Stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
    resolver_timeout 2s;

    # # Limits
    # limit_req_log_level warn;
    # limit_req_zone $binary_remote_addr zone=reqlimit:10m rate=10r/m;

    # limit_conn_zone $binary_remote_addr zone=connlimit:100m;
    # limit_conn servers 1000; # Simultaneous Connections

    # Enable PageSpeed
    pagespeed off;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;

    # https://www.fastfwd.com/installing-google-pagespeed-module-apache-nginx/
    # pagespeed RewriteLevel OptimizeForBandwidth;
    
    # # Lazy Load Images
    # pagespeed EnableFilters lazyload_images;

    # # Responsive Images
    # pagespeed EnableFilters responsive_images,resize_images;

    # Inline CSS
    #pagespeed EnableFilters inline_css;
    #pagespeed CssInlineMaxBytes 4096;

    # Defer JavaScript
    #pagespeed EnableFilters defer_javascript;

    # Combine JavaScript
    #pagespeed EnableFilters combine_javascript;

    # Combine CSS
    #pagespeed EnableFilters combine_css;

    # Collapse Whitespace
    #pagespeed EnableFilters collapse_whitespace;

    include /etc/nginx/conf.d/*.conf;
}

# server {
#     listen 443 ssl http2;

#     #Removing Old and Insecure Cipher Suites if available and add the following.
#     ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;  
# }

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

And the sever.conf configuration file

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

include "/etc/nginx/plesk.conf.d/ip_default/*.conf";

server {
    listen 192.168.0.1:443 ssl;

    ssl_certificate             "/usr/local/psa/var/certificates/scfPy3659";
    ssl_certificate_key         "/usr/local/psa/var/certificates/scfPy3659";
    client_max_body_size 2048m;

    proxy_read_timeout 600;
    proxy_send_timeout 600;

    proxy_max_temp_file_size 0;
    proxy_buffers 16 16k;
    proxy_buffer_size 32k;
    proxy_busy_buffers_size 32k;

    # fastcgi_buffers 8 16k;
    # fastcgi_buffer_size 32k;

    server_name _;

    location / {
        proxy_pass http://127.0.0.1:8880;
        proxy_redirect http://$host:8880 $scheme://$host;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        access_log off;

        gzip on;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    }

    location ~ /ws$ {
        proxy_pass http://127.0.0.1:8880;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        access_log off;
    }

    underscores_in_headers on;
}

server {
    listen 192.168.0.1:8080;

    location ^~ /plesk-site-preview/ {
        proxy_pass http://127.0.0.1:8880;
        proxy_set_header Host               plesk-site-preview.local;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_cookie_domain plesk-site-preview.local $host;
        access_log off;
    }

    location / {
        proxy_pass http://192.168.0.1:7080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

And this I’m running Magento I’ve included and ran the nginx.conf.sample file that comes by default.

I’ve tried many solutions but none has worked, the one thing I’m avoiding is to run gzip off as some suggestions this will slow the website. Besides this issue happens when many requests are sent to the server. I tried to open 5 pages of the website in 5 chrome tabs then this error starts.