# \[SOLVED\] 502 Bad Gateway after 4.4.5 Update, Failed To Create Index Error in Mattermost

**URL:** <https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343>\
**Category:** Troubleshooting\
**Created:** [January 10, 2018, 10:40pm UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343 "2018-01-10T22:40:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradmb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/bradmb/32/1798_2.png) [@bradmb](https://forum.mattermost.com/u/bradmb)\
**Post date:** [January 10, 2018, 10:40pm UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/1 "2018-01-10T22:40:51Z")

</div>

Hi all,

I upgraded Mattermost to 4.4.5 (via GitLab 10.3.3’s Omnibus Upgrade) and now the Mattermost web interface is returning a 502 Bad Gateway error.

**I’m looking in the Mattermost logs and see this repeatedly:**  
[2018/01/10 15:38:51 MST] [CRIT] Failed to create index pq: relation “idx\_posts\_channel\_id\_delete\_at\_create\_at” does not exist  
[2018/01/10 15:38:51 MST] [CRIT] Failed to create index pq: canceling statement due to user request

My guess is a database update failed at some point? Any ideas on what I can do to fix the underlying issue?

---

<div class="post-metadata">

**Author:** ![bradmb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/bradmb/32/1798_2.png) [@bradmb](https://forum.mattermost.com/u/bradmb)\
**Post date:** [January 12, 2018, 3:36pm UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/2 "2018-01-12T15:36:47Z")

</div>

For anyone referencing this, I was able to fix this. I logged into the Mattermost database (sudo gitlab-psql -d mattermost\_production) and ran the following query to create the missing index:

CREATE INDEX idx\_posts\_channel\_id\_delete\_at\_create\_at ON Posts (ChannelId,DeleteAt,CreateAt)

---

<div class="post-metadata">

**Author:** ![Spone](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/spone/32/2367_2.png) [@Spone](https://forum.mattermost.com/u/Spone)\
**Post date:** [September 13, 2018, 4:47pm UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/3 "2018-09-13T16:47:31Z")

</div>

Hello, I have a similar error:

> Failed to create index pq: relation "idx\_channel\_search\_txt" does not exist, pq: invalid multibyte character for locale

Where did you find the query to run?

---

<div class="post-metadata">

**Author:** ![bradmb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/bradmb/32/1798_2.png) [@bradmb](https://forum.mattermost.com/u/bradmb)\
**Post date:** [September 13, 2018, 5:59pm UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/4 "2018-09-13T17:59:31Z")

</div>

In the Mattermost repository. For your index, I found it here:

> <https://github.com/mattermost/mattermost-server/blob/8b17bf9e42dd56ecd0fe8300da90bea5ee8684ef/store/sqlstore/channel_store.go#L301>

So your index you need to create is likely:  
CREATE INDEX idx\_channel\_search\_txt ON Channels (Name, DisplayName, Purpose)

---

<div class="post-metadata">

**Author:** ![Spone](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/spone/32/2367_2.png) [@Spone](https://forum.mattermost.com/u/Spone)\
**Post date:** [September 14, 2018, 8:28am UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/5 "2018-09-14T08:28:33Z")

</div>

Thank you for the quick reply!!

---

<div class="post-metadata">

**Author:** ![Spone](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/spone/32/2367_2.png) [@Spone](https://forum.mattermost.com/u/Spone)\
**Post date:** [September 14, 2018, 11:21am UTC](https://forum.mattermost.com/t/solved-502-bad-gateway-after-4-4-5-update-failed-to-create-index-error-in-mattermost/4343/6 "2018-09-14T11:21:44Z")

</div>

In my case, the error was actually the symptom for another issue. Here are the details if it can help someone else: [https://github.com/mattermost/mattermost-server/issues/9409](https://github.com/mattermost/mattermost-server/issues/9409)
