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 such as PDF and JPG. Nevertheless, something was preventing local uploads for some file types.

I can upload a PDF but a JPG would thrown an error.

My project was using Laravel Filament and the SpatieMediaLibraryFileUpload. Looking in the Chrome Network tab, I see a 500 error. The response shows a 500 error from Nginx, and not Laravel.

On an ARM macOS I ran tail -f /opt/homebrew/var/log/nginx/error.log and saw the this 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 was able to resolved the issue by by running sudo chown -R $USER:_developer client_body_temp/

I don’t know what led to this error. I am unsure why nobody was assigned to the folders. I also think that it may have had something to do with how my work laptop is managed because I don’t think 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!