Some images not showing and failed to open stream: permission denied on image upload


A live website has stopped working properly, there are two symptoms:

  • Many images are not loading (500) both in the frontend and in the panel
  • Trying to upload an image returns ‘failed to open stream: permission denied’

When looking at the server logs the images that are returning 500 are being searched for in media folders that do not exist, in general it seems the numeric value of the media folder is different. So for the following log: - - [17/Aug/2020:21:25:45 -0400] "GET /media/pages/censored/blog/el-desarraigo/1461537514-1597279393/desarraigo-scaled.jpg HTTP/1.1" 500 181 "censored" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/xx.x.xxxx.xx/ Safari/537.36"

There exists the following media folder:


…with the asked file and others.

I believe this is a permissions problem, because on some of these folders the group does not have write permissions, they are 644, and I believe apache is group. Which would not allow it to WRITE to these folder. But still, why are there folder with numeric names that differ from those that kirby is trying to actually serve ?

Btw, I do not have full access to this server, I do have ssh access, but quite limited, and not to the logs, I had to ask for them.

There has not been afaik any recent code changes, but there was a recent server modification which I am not sure what entailed, which reinforces my suspicion they messed up permissions. I already told them that, but they think it is kirby router, so I wanted to check out with you.

Thank you.

As a first means, I’d remove the media folder so that stuff gets regenerated. You will then see if the folders is actually re-generated. If not, you actually have to check permissions/file ownership.

1 Like

It did seem to be a permissions problem, for reasons unknown some of the content folders and their corresponding media folders did not have write permissions for the group (apache), so, there. They fixed it.