You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't update fields of an already uploaded media using the S3 adapter #7037
Whenever I want to update a field (e.g. Alt field), I get a 500 error when I try to submit the form.
Here is the log from the console
Reproduction Steps
Install Payload v3.0.0-beta.56 with the default Media Collection
Install @payloadcms/storage-s3 v3.0.0-beta.56
Set up S3 storage (I tried both on minIO and AWS S3 and I get the same behavior)
Upload a first Media
Update the Alt field and submit the form
Hi @PatrikKozak I have the same issue in local (using a dockerized MinIO instance) and on my staging environment using an AWS S3 bucket so it doesn't seem to be a setup issue.
@fofoy Thanks for the info - hmm unfortunately there isn't enough here to fully understand what could be causing this issue.
A couple things though, could you try and log out some of the info in that function where the error is coming from (in your node_modules) - this may be able to give us some more information
Also, could you update your payload packages versions to latest (just in case) - I'd like to get to the bottom of this but just will need more info to continue
@PatrikKozak Thanks, I had the time to update my project to latest beta version 91 and the problem remains, I'll dig further to see where it's going wrong and I'll let you know.
changed the title [-]Can't update fields of an already updoaded media using the S3 adapter[/-][+]Can't update fields of an already uploaded media using the S3 adapter[/+]on Aug 27, 2024
and here is the actual error when trying to fetch the file :
TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getExternalFile (webpack-internal:///(rsc)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected]
a48-202_bgnc5eiwwsaz2mukappcno4s3m/node_modules/payload/dist/uploads/getExternalFile.js:18:21) {
cause: Error: connect ECONNREFUSED 127.0.0.1:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 443
}
}
⨯ unhandledRejection: TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getExternalFile (webpack-internal:///(rsc)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected]
a48-202_bgnc5eiwwsaz2mukappcno4s3m/node_modules/payload/dist/uploads/getExternalFile.js:18:21) {
cause: Error: connect ECONNREFUSED 127.0.0.1:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 443
}
}
⨯ unhandledRejection: TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getExternalFile (webpack-internal:///(rsc)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected]
a48-202_bgnc5eiwwsaz2mukappcno4s3m/node_modules/payload/dist/uploads/getExternalFile.js:18:21) {
cause: Error: connect ECONNREFUSED 127.0.0.1:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 443
}
}
So it seems like it's something to do with the network. I'm running everything in Docker with several containers for the postgres db, the S3 instance (minIO) and the payload admin but it also does the same on our dev cluster (kubernetes) with an AWS S3 instance connected to it.
I'm having the same problem as well. I can't edit any fields of an already uploaded file, and I got the same error as described above.
We also run our environments in kubernetes and we use Google cloud storage for storing files. I have however noticed that when I'm running payload locally (and still using google cloud storage for storing files) it works. When I'm running payload in docker I get the same error we got in our kubernetes environments.
@fofoy Have you found any temporary workaround for this problem?
Hi @nickejoha, I didn't have the time to dig any further than this yet as I need to make progress on my current project but that's definitely something that needs to be sorted, I'll try to invest more time in a bit.
I'm also experiencing the same issue; I'm using the S3 Adapter with a Cloudflare R2 bucket, and everything works fine when it comes to creating, reading, and deleting operations, but update does not work. Here is my error printout when I try to update the "description" field:
[01:56:38] ERROR: There was a problem while uploading the file. Blocked unsafe attempt to http://localhost:6002/api/media/file/SCR-20250523-jnsh.png
err: {
"type": "FileRetrievalError",
"message": "There was a problem while uploading the file. Blocked unsafe attempt to http://localhost:6002/api/media/file/SCR-20250523-jnsh.png",
"stack":
FileRetrievalError: There was a problem while uploading the file. Blocked unsafe attempt to http://localhost:6002/api/media/file/SCR-20250523-jnsh.png
at generateFileData (file:///Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/uploads/generateFileData.js:53:19)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async updateByIDOperation (file:///Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/updateByID.js:80:61)
at async updateByIDHandler (file:///Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/endpoints/updateByID.js:16:17)
at async handleEndpoints (file:///Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/utilities/handleEndpoints.js:169:26)
at async /Users/firatciftci/Developer/misc/artsumer/.next/server/chunks/node_modules__pnpm_94f68aa0._.js:29799:26
at async AppRouteRouteModule.do (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.dev.js:26:34112)
at async AppRouteRouteModule.handle (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.dev.js:26:41338)
at async doRender (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:1518:42)
at async DevServer.renderToResponseWithComponentsImpl (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:1920:28)
at async DevServer.renderPageComponent (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:2408:24)
at async DevServer.renderToResponseImpl (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:2445:32)
at async DevServer.pipeImpl (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:1008:25)
at async NextNodeServer.handleCatchallRenderRequest (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/next-server.js:305:17)
at async DevServer.handleRequestImpl (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/base-server.js:900:17)
at async /Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/dev/next-dev-server.js:371:20
at async Span.traceAsyncFn (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/trace/trace.js:157:20)
at async DevServer.handleRequest (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/dev/next-dev-server.js:368:24)
at async invokeRender (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/lib/router-server.js:237:21)
at async handleRequest (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/lib/router-server.js:428:24)
at async requestHandlerImpl (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/lib/router-server.js:452:13)
at async Server.requestListener (/Users/firatciftci/Developer/misc/artsumer/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_b5160444ab580599d92acf97540046d0/node_modules/next/dist/server/lib/start-server.js:158:13)
"data": null,
"isOperational": true,
"isPublic": false,
"status": 500,
"name": "FileRetrievalError"
}
PATCH /api/media/1977?depth=0&fallback-locale=null 500 in 406ms
Important to note that, if I turn off the upload.filesRequiredOnCreate flag, create a new Media item with no image, and then edit its "description" field, I have no issues updating it. This only occurs when there is an image attached.
I have also checked the Content-Length and the "origin" header of the update request, and those seem to be all fine.
I think this is a new error (@firatciftci and @tsemachh and also me 😀 are having) It seems to have started with version 0.43.0.
Downgrading to 0.42.0 fixes it for me. I also tested 0.39.0-0.42.0 no issues there as well.
Openshift service name as hostname will not work because safeFetch() will attempt to do a DNS lookup and disallow private IP address. Which I think is a bug on Payloadcms side cc @kendelljoseph@DanRibbens
This issue hasn’t had activity in a while and relates to several releases ago, so we’re going to close it for now. If it’s still occurring on the latest version, please open a new issue with updated reproduction steps and environment details so we can investigate.
Activity
fofoy commentedon Aug 7, 2024
Any news on this one ? Is there anything I can help you with @PatrikKozak ?
PatrikKozak commentedon Aug 7, 2024
Hey @fofoy - we'll get right on this!
PatrikKozak commentedon Aug 8, 2024
Hi @fofoy - I did some testing on my end and was not able to reproduce the above issue.
It may have something to do with your S3 storage setup - do you have a reverse proxy setup?
Is this purely local?
Just want to get some additional information before I can dig deeper into this - thank you!
fofoy commentedon Aug 8, 2024
Hi @PatrikKozak I have the same issue in local (using a dockerized MinIO instance) and on my staging environment using an AWS S3 bucket so it doesn't seem to be a setup issue.
PatrikKozak commentedon Aug 8, 2024
@fofoy Thanks for the info - hmm unfortunately there isn't enough here to fully understand what could be causing this issue.
A couple things though, could you try and log out some of the info in that function where the error is coming from (in your node_modules) - this may be able to give us some more information
Also, could you update your payload packages versions to latest (just in case) - I'd like to get to the bottom of this but just will need more info to continue
fofoy commentedon Aug 27, 2024
@PatrikKozak Thanks, I had the time to update my project to latest beta version 91 and the problem remains, I'll dig further to see where it's going wrong and I'll let you know.
[-]Can't update fields of an already updoaded media using the S3 adapter[/-][+]Can't update fields of an already uploaded media using the S3 adapter[/+]fofoy commentedon Sep 23, 2024
Hi @PatrikKozak here is the result of logging the Promise
getExternalFileon line 41 ofgenerateFileData.jsfile:and here is the actual error when trying to fetch the file :
So it seems like it's something to do with the network. I'm running everything in Docker with several containers for the postgres db, the S3 instance (minIO) and the payload admin but it also does the same on our dev cluster (kubernetes) with an AWS S3 instance connected to it.
nickejoha commentedon Oct 17, 2024
Hi @PatrikKozak and @fofoy
I'm having the same problem as well. I can't edit any fields of an already uploaded file, and I got the same error as described above.
We also run our environments in kubernetes and we use Google cloud storage for storing files. I have however noticed that when I'm running payload locally (and still using google cloud storage for storing files) it works. When I'm running payload in docker I get the same error we got in our kubernetes environments.
@fofoy Have you found any temporary workaround for this problem?
fofoy commentedon Oct 17, 2024
Hi @nickejoha, I didn't have the time to dig any further than this yet as I need to make progress on my current project but that's definitely something that needs to be sorted, I'll try to invest more time in a bit.
14 remaining items
firatciftci commentedon Jun 18, 2025
I'm also experiencing the same issue; I'm using the S3 Adapter with a Cloudflare R2 bucket, and everything works fine when it comes to creating, reading, and deleting operations, but update does not work. Here is my error printout when I try to update the
"description"field:Important to note that, if I turn off the
upload.filesRequiredOnCreateflag, create a new Media item with no image, and then edit its"description"field, I have no issues updating it. This only occurs when there is an image attached.I have also checked the
Content-Lengthand the"origin"header of the update request, and those seem to be all fine.tsemachh commentedon Jun 19, 2025
Happens also to me on local storage and also on GCS storage so it's not related to S3
Look at #12622 (comment)
Same error occurs in other places
thopedam commentedon Jun 19, 2025
I think this is a new error (@firatciftci and @tsemachh and also me 😀 are having) It seems to have started with version 0.43.0.
Downgrading to 0.42.0 fixes it for me. I also tested 0.39.0-0.42.0 no issues there as well.
EDIT: a new issue has been added: #12876
kendelljoseph commentedon Jun 25, 2025
@firatciftci #12927 should fix the problem.
fix: get external resource blocked (#12927)
greenlover1991 commentedon Aug 13, 2025
Just want to share based on our setup in above comment after upgrading to v3.46.0:
Production setup:
The
pasteURLthat didn't worked:The
pasteURLthat finally worked:Openshift service name as hostname will not work because
safeFetch()will attempt to do a DNS lookup and disallow private IP address. Which I think is a bug on Payloadcms side cc @kendelljoseph @DanRibbenshttps://github.com/payloadcms/payload/blob/v3.46.0/packages/payload/src/uploads/safeFetch.ts#L20
Related to #13146
JessRynkar commentedon Jan 19, 2026
This issue hasn’t had activity in a while and relates to several releases ago, so we’re going to close it for now. If it’s still occurring on the latest version, please open a new issue with updated reproduction steps and environment details so we can investigate.
github-actions commentedon Jan 27, 2026
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.