How to fix Nginx client_body_temp Permission denied on macOS

Categories: Development, Trouble Shooting

I was working on a project that required file uploads like PDF/JPG. And it wouldn’t be a fun time unless something went wrong.
In my case, I could upload a PDF but a JPG would thrown an error. My project is using Laravel Filament and the SpatieMediaLibraryFileUpload. Looking in the Chrome Network tab I could see a 500 error and the response shows a 500 error, but from Nginx and not Laravel.

On an ARM macOS I ran tail -f /opt/homebrew/var/log/nginx/error.log and could see the following error.

2023/08/11 09:53:43 [crit] 29890#0: *9 open() "/opt/homebrew/var/run/nginx/client_body_temp/0000000002" failed (13: Permission denied), client: 127.0.0.1, server: local.test, request: "POST /livewire/upload-file?expires=1691769523&signature=61f7f20ef5a9047cec174fc9fa5dbb2b729b0f91394f75b23d41c0f358318463 HTTP/1.1", host: "local.test", referrer: "http://local.test/admin/inspections/5/submit"

🤨 WTF!

I resolved the issue by by running sudo chown -R $USER:_developer client_body_temp/

I am unclear why nobody was assigned to the folders, I also think that maybe my work laptop has the _developer group which I don’t think is standard.

You won’t need to restart Nginx but retry the file upload.

Hopefully you found this helpful!


Adam Patterson

Adam Patterson

User Interface Designer & Developer with a background in UX. I have spent 5 years as a professionally certified bicycle mechanic and ride year-round.

I am a husband and father of two, I enjoy photography, music, movies, coffee, and good food.

You can find me on Twitter, Instagram, and YouTube!