Upstream Prematurely Closed connection while reading upstream client

0
I’m facing an issue with file downloads in my application. A few months ago, I uploaded an Excel template. When I try to download that old template now, the download does not work. At runtime there’s no visible error, but in the logs I see:CodeUpstream Prematurely Closed connection while reading upstream client When I debug the microflow, I can see the file metadata (name, size, hasContent = true), so the file object exists. However, the download still fails. Interestingly, if I upload the same template again as a new file, the download works perfectly.Why does the old upload fail while the new upload succeeds? What could be causing this “Upstream Prematurely Closed connection” error, and what’s the recommended solution to prevent this from happening again?
asked
1 answers
1

Hi Selvarani,
The most likely cause is not the Download File activity, but that the old FileDocument metadata exists while the actual binary content cannot be retrieved correctly from the file storage.


Mendix stores the FileDocument data separately from the normal entity data; the file content is handled through the application's file/blob storage.


Since:

  • The old record has HasContents = true
  • Its metadata (name/size) is available
  • The old file fails to download
  • Uploading the same file again creates a new working FileDocument


I would suspect corrupted/missing/inaccessible binary content for that particular old FileDocument, or an issue with the underlying file storage. HasContents = true by itself doesn't prove that the binary can actually be successfully streamed.


The Upstream Prematurely Closed connection message means the connection was terminated while the response/file was being transferred. Mendix also documents similar premature-connection errors around file transfers.


What I would do


First, test whether other old FileDocuments uploaded around the same period also fail.

  • If only this file fails → replace/re-upload that FileDocument.
  • If many older files fail → investigate the application's file storage/backup/restore/storage configuration rather than the microflow.


Also test the file using a standard File Manager or Download File activity. If the newly uploaded file works through exactly the same flow, that further confirms the problem is with the old file's stored content rather than your microflow.


I would not try to fix this by changing HasContents or directly modifying the database. If multiple existing files are affected, provide Mendix Support with the affected FileDocument IDs and the exact timestamp/logs of a failed download so they can investigate the underlying storage.


Kindly mark this as the accepted answer if it helps.

answered