Upstream prematurely closed connection while reading response header from upstream

Nội dung

This problem happened because your upstream (php, php-fpm) max_execution_time is shorter than proxy_connect_timeout in your nginx proxy.

For example:

In my php.ini:

max_execution_time = 30

But in mysite.conf have:

location / {
     proxy_set_header        Host $server_name;
     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_pass http://localhost:8080;
     proxy_read_timeout 300; 
     proxy_connect_timeout 300;  # <== this
     proxy_request_buffering off;
     proxy_buffering off;
     proxy_redirect off;
 }

Then I got in error.log of nginx:

[error] 117#117: *434 upstream prematurely closed connection while sending to client….

To resolve this problem, increase your max_execution_time to 300.

That all!

Additional info: https://stackoverflow.com/questions/49508218/upstream-prematurely-closed-connection-while-reading-response-header-from-upstre

Anthony Nguyễn

Cây bút chính tại VietnamTutor

Bài viết cùng chuyên mục

WordPress 10x: 10 Bước Tăng Tốc Website Nhanh Gấp 10 Lần (2026)

Hướng dẫn chi tiết 10 bước tăng tốc WordPress lên gấp 10 lần trong năm 2026 — từ hosting, caching, tối ưu ảnh đến Speculative Loading

WordPress Caching 2026: So Sánh 5 Loại Cache Và Cách Chọn Đúng

So sánh 5 loại cache cho WordPress năm 2026: Page Cache, Object Cache (Redis/Memcached), OPcache, CDN Cache và Database Query Cache. Hướng dẫn chọn đúng loại

Core Web Vitals 2026: Cách Đo Và Tối Ưu LCP, INP, CLS Cho WordPress

Hướng dẫn đo và tối ưu Core Web Vitals (LCP, INP, CLS) cho WordPress năm 2026. Cách đạt điểm cao trên PageSpeed Insights và cải thiện

Measure JavaScript Performance 2026

Hướng dẫn đo lường hiệu năng JavaScript 2026: Từ DevTools, Performance API, đến Core Web Vitals. Bao gồm 7 công cụ thực chiến, code ví dụ