Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sqharriger's avatar

PDF Download gets "Failed - Network Error" on Chrome

I'm trying to do a simple download of a single pdf file (code below). I believe I'm getting the error because the server is cutting off the connection before finishing the download (chunking?). This happens maybe 20% of the time. The files that fail have no rhyme or reason. Sometimes the same file that failed 4 times works the next try. I'm using Forge and the cheapest DO option.

In Chrome this materializes as the file showing in the download bar with "Failed - Network Error". I can then choose "Resume" download and it will work once or twice.

Has anyone else come across this issue?

public function show()
    {
        $pathToFile = storage_path(). '/app/' .$this->path;
        $name = $this->user->first_name . ' ' . $this->user->last_name;
        $headers = array(
            'Content-Type' => 'application/pdf',
        );
        return response()->download($pathToFile, $name, $headers);
    }
0 likes
5 replies
burlresearch's avatar

check your Laravel logs - there is probably a stack dump for each occurence - this will probably tell you what is going on.

storage/logs/laravel.log

sqharriger's avatar

Hey thanks for the suggestion. Nothing is coming up in the Laravel logs, though.

burlresearch's avatar

If nothing in Laravel side then it must be downstream - this isn't only in Chrome, I assume? must be something with maybe php.ini, or nginx? Strange that you'd see a Network Error?

Sorry, not enough to go on here for me...

stuartcusack's avatar

Just in case you are in the same boat as me. I had an old Laravel 5.7 installation and downloads broke after switching to CloudFlare.

It seems HTTP/2 and HTTP/3 have stricter rules, and L5.7 seems to be failing the checks. I suspect this is because there is whitespace or something being outputted by the old L5.7 download method.

So the solution:

ob_clean ( )
return Storage::disk('local')->download($pathToFile);
ImeDa's avatar

Is it tomeouting or what ? Does it throw the error after some seconds or does it immediately ? If it happens after some seconds you have to increase php execution time. You can do it from forge's admin panel.

Please or to participate in this conversation.