I was just able to reproduce this twice on a new test Discourse site.
- Edit a category - in this case, the category had a sub category.
- Go to the Images tab.
- Change the Category Background Image.
- Save and wait
- Discourse “crashes” for ~ 10 seconds and forwards you to an Nginx Bad Gateway error page.