# Error 500 on category page and homepage after upgrade to 2.6

**URL:** <https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155>\
**Category:** Self-hosting\
**Created:** [August 26, 2020, 5:07pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155 "2020-08-26T17:07:53Z")\
**Posts on this page:** 16\
**Page:** 1

## AI-generated summary

After upgrading Discourse from 2.4 to 2.6, [Olivier_Baillon](/t/-/162155/1) encountered a persistent Error 500 on the homepage and category pages, despite successful rebuilds and working admin/user interfaces. Logs repeatedly showed a `NoMethodError (undefined method 'hex' for nil:NilClass)` originating from `app/models/upload.rb` and traced to `group.rb:767` in `flair_url` [4](/t/-/162155/4). Safe mode and plugin deactivation didn’t help [5](/t/-/162155/5). Initially suspected category images [8](/t/-/162155/8), but none were present [10](/t/-/162155/10). [michaeld](/t/-/162155/11) correctly identified corrupted or missing group flair uploads as the culprit and advised removing or reuploading group flair avatars [13](/t/-/162155/13). [pfaffman](/t/-/162155/14) confirmed the fix and provided a Rails console snippet to identify and repair affected groups, which resolved the issue. [Olivier_Baillon](/t/-/162155/15) thanked both for their help, acknowledging he wouldn’t have found the solution alone.

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 26, 2020, 5:07pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/1 "2020-08-26T17:07:53Z")

</div>

Hi,

I just have upgraded my forum ( working since 2017 ) to 2.6 ( from 2.4)  
During the upgrade i notice that Postgresql 9.5 has been replaced by postgres 12.

the rebuild operation has ended without errors but i have an error 500 on homepage ( or a oops message )  
Same error on category page.  
The admin is working, the user profil is working , the user list is working, a single post is working.  
The top refered in admin is not working.

I have no ideas to solve that.  
Thanks you very much

---

<div class="post-metadata">

**Author:** ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)\
**Post date:** [August 26, 2020, 5:17pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/2 "2020-08-26T17:17:03Z")

</div>

Any plugin installed?

> [@Using Safe Mode to troubleshoot issues with themes and plugins](https://meta.discourse.org/t/using-safe-mode-to-troubleshoot-issues-with-themes-and-plugins/53504/1):
>
> Discourse has a “JavaScript [Safe Mode](https://meta.discourse.org/t/53504?silent=true)” **any** user can use to isolate the root cause of a JavaScript issue.
> 
> To access [safe mode](https://meta.discourse.org/t/53504?silent=true) go to:
> 
> `http://your-site-name/safe-mode` for example this is the [safe mode](https://meta.discourse.org/t/53504?silent=true) for meta:

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [August 26, 2020, 7:37pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/3 "2020-08-26T19:37:40Z")

</div>

Anything in `/logs`?

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 7:16am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/4 "2020-08-27T07:16:04Z")

</div>

You are right, i have many many times the same error in /logs

NoMethodError (undefined method `hex' for nil:NilClass) app/models/upload.rb:180:in `base62\_sha1’  
app/models/upload.rb:174:in `short_path' app/models/upload.rb:146:in `short\_path’  
app/models/group.rb:767:in `flair_url' (eval):5:in `\_fast\_attributes’  
lib/freedom\_patches/ams\_include\_without\_root.rb:54:in `include!' lib/freedom_patches/ams_include_without_root.rb:57:in `include!’  
lib/freedom\_patches/ams\_include\_without\_root.rb:57:in `include!' app/controllers/application_controller.rb:440:in `serialize\_data’  
app/controllers/application\_controller.rb:449:in `render_serialized' lib/topic_list_responder.rb:16:in `block (2 levels) in respond\_with\_list’  
lib/topic\_list\_responder.rb:9:in `respond_with_list' app/controllers/list_controller.rb:102:in `block (2 levels) in class:ListController’  
app/controllers/list\_controller.rb:107:in `public_send' app/controllers/list_controller.rb:107:in `block (2 levels) in class:ListController’  
app/controllers/application\_controller.rb:340:in `block in with_resolved_locale' app/controllers/application_controller.rb:340:in `with\_resolved\_locale’  
lib/middleware/omniauth\_bypass\_middleware.rb:68:in `call' lib/content_security_policy/middleware.rb:12:in `call’  
lib/middleware/anonymous\_cache.rb:336:in `call' config/initializers/100-quiet_logger.rb:19:in `call’  
config/initializers/100-silence\_logger.rb:31:in `call' lib/middleware/enforce_hostname.rb:22:in `call’  
lib/middleware/request\_tracker.rb:176:in `call’

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 7:18am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/5 "2020-08-27T07:18:41Z")

</div>

Unfortunatly, go to [safe mode](https://meta.discourse.org/t/53504?silent=true) and unactive everything d’ont resolve the problem.  
I still have the error.

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 7:34am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/6 "2020-08-27T07:34:30Z")

</div>

I have many many times this error in logs :

NoMethodError (undefined method `hex' for nil:NilClass) app/models/upload.rb:180:in `base62\_sha1’ app/models/upload.rb:174:in `short_path' app/models/upload.rb:146:in `short\_path’ app/models/group.rb:

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 7:39am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/7 "2020-08-27T07:39:13Z")

</div>

And in the admin dashboard, some metrix ( Top Referred Topics ) give an error :  
“sorry, request take too much time”

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [August 27, 2020, 10:22am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/8 "2020-08-27T10:22:36Z")

</div>

I have seen this once, the issue was that the category images were missing. Discourse tries to retrieve their dimensions and fails.

You might try to remove any category images.

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 10:41am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/9 "2020-08-27T10:41:16Z")

</div>

I tried to restore but i have an error :

[2020-08-27 10:06:41] Pausing sidekiq…  
[2020-08-27 10:06:41] Waiting up to 60 seconds for Sidekiq to finish running jobs…  
[2020-08-27 10:38:40] EXCEPTION: ERROR: deadlock detected  
DETAIL: Process 594 waits for AccessExclusiveLock on relation 1113165 of database 16569; blocked by process 1617.  
Process 1617 waits for AccessShareLock on relation 1113221 of database 16569; blocked by process 594.  
HINT: See server log for query details.  
CONTEXT: SQL statement “ALTER TABLE public.categories SET SCHEMA backup;”  
PL/pgSQL function inline\_code\_block line 11 at EXECUTE

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 10:45am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/10 "2020-08-27T10:45:04Z")

</div>

We don’t have category image ☹

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [August 27, 2020, 10:47am UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/11 "2020-08-27T10:47:14Z")

</div>

> [@Olivier\_Baillon](#):
>
> app/models/group.rb:767:in `flair_url'`

Hmm 🤔  
Group flair maybe?

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 1:10pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/12 "2020-08-27T13:10:35Z")

</div>

how to know if the problem come from group flair and how to solve that ?  
Thanks you very much

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [August 27, 2020, 1:33pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/13 "2020-08-27T13:33:10Z")

</div>

Try to remove or reupload the group avatar flair from any groups and see if it solves the issue.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [August 27, 2020, 3:11pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/14 "2020-08-27T15:11:41Z")

</div>

That did it, @michaeld! Nice work. @Olivier_Baillon, you can mark Michael’s post as the solution!

If anyone else has this, you’d do something like:

```plaintext
cd /var/discourse
./launcher enter app
rails c
Group.all.pluck(:id,:flair_icon,:flair_upload_id)
# for the groups that have `flair_upload_id` something like
g=Group.find(GROUP_ID_FROM_THE_LIST) # that's id not flair_upload_id
g.flair_upload
g.save

```

There are more elegant ways, but if you have just a few this should get you started.

---

<div class="post-metadata">

**Author:** ![Olivier\_Baillon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivier_baillon/32/72271_2.png) [@Olivier\_Baillon](https://meta.discourse.org/u/Olivier_Baillon)\
**Post date:** [August 27, 2020, 3:56pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/15 "2020-08-27T15:56:26Z")

</div>

THANKS @michaeld and @pfaffman  
I would never have found that myself.  
Thanks you very much

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [September 26, 2020, 4:09pm UTC](https://meta.discourse.org/t/error-500-on-category-page-and-homepage-after-upgrade-to-2-6/162155/16 "2020-09-26T16:09:32Z")

</div>

Closed on September 26, 2020, 4:09pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
