Chrome shows net::ERR_INCOMPLETE_CHUNKED_ENCODING on a PHP page
net::ERR_INCOMPLETE_CHUNKED_ENCODINGShort answer
The browser got a chunked response that ended before its final zero-length chunk, so the connection closed mid-page. With PHP the usual reasons are a read timeout in the web server or the script being stopped by PHP or PHP-FPM before it finished. Find the timeout that matches how long the failing request ran, and raise it or shorten the work.
Fix it fast
1Find out which cause you have
Time the failing request and read the web server error log at the same moment. A failure after a round number of seconds (30, 60) points straight at a timeout.
time curl -sS -o /dev/null -w '%{http_code} %{size_download}\n' https://example.com/slow-report.php sudo tail -n 20 /var/log/nginx/error.log2Match what you see, then jump to its fix
- 1
The request fails after about 60 seconds, and the nginx error log mentions a timeout while reading the response from upstreamnginx stops waiting for PHP-FPM (fastcgi_read_timeout)Fix - 2
The failure comes at 30 seconds, or at the value of request_terminate_timeoutPHP or PHP-FPM terminates the script before it finishesFix
- 1
What does the error look like?
net::ERR_INCOMPLETE_CHUNKED_ENCODINGThe page loads partly, then the response stops
Cause 1 of 2
nginx stops waiting for PHP-FPM (fastcgi_read_timeout)
1Check
nginx's fastcgi_read_timeout defaults to 60 seconds. It applies between two reads, and when PHP sends nothing for that long, nginx closes the connection. A closed connection before the last chunk is, by RFC 9112, an incomplete message, which the browser reports.
grep -rn "fastcgi_read_timeout" /etc/nginx/
sudo tail -n 20 /var/log/nginx/error.log | grep -i timed2Fix
Make the slow request faster, or raise the timeout for that location only.
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_read_timeout 180s;
}3Verify
The slow request completes in curl with the expected size.
sudo nginx -t && sudo systemctl reload nginx && curl -sS -o /dev/null -w '%{http_code} %{size_download}\n' https://example.com/slow-report.phpConfirmed by nginx.org
Cause 2 of 2
PHP or PHP-FPM terminates the script before it finishes
1Check
max_execution_time defaults to 30 seconds for web requests and ends the script when exceeded. PHP-FPM's request_terminate_timeout kills the worker for a request after its limit; its default 0 means off.
php -r 'echo ini_get("max_execution_time"), "\n";'
grep -rn "request_terminate_timeout" /etc/php/2Fix
Raise max_execution_time for the script that needs it, and make sure request_terminate_timeout is not lower than it. Better, move the long job to a queue and return at once.
<?php
set_time_limit(120); // at the top of the long-running script3Verify
The request now returns a full response.
curl -sS -o /dev/null -w '%{http_code} %{size_download}\n' https://example.com/slow-report.phpConfirmed by php.net
How do I stop it coming back?
- Keep web requests short; run reports and exports in a background job and send the user a link.
- Log the duration of slow requests, so a timeout is found before users see it.
- When you raise one timeout, check the others in the chain (nginx, PHP-FPM, PHP, any proxy).
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Back end
CodeIgniter works locally but every page is 404 on the live server
The requested URL was not found on this server.
A 404 on the live server comes from one of four places: the document root is not the public folder, Apache ignores .htaccess or nginx has no try_files rule, the route is not defined because auto routing is off, or the controller file name differs from its class in case.
5 causes, each with a fixBack end
Laravel file upload returns 413 behind nginx
413 Content Too Large
A 413 means a limit refused the request body before Laravel could use it.
3 causes, each with a fixBack end
Laravel routes return 404 or throw NotFoundHttpException
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
A 404 means Laravel found no route for that URL, or the request never reached Laravel at all.
3 causes, each with a fixBack end
Livewire uploads work locally but fail behind nginx on the server
$_POST and $_FILES are empty (PHP discards a body over post_max_size)
Three separate limits stop a large upload, and a local dev server hides two of them.
3 causes, each with a fixBack end
Your plain PHP endpoint sets CORS headers but the browser still blocks it
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/save.php:1)
The headers only help if they are sent on every response the browser looks at, starting with the OPTIONS preflight.
3 causes, each with a fixBack end
echo and flush() in PHP show nothing until the script finishes
flush() has no visible effect in the browser
flush() only empties PHP's own system buffers.
2 causes, each with a fix