# Moving posts returns 502 bad gateway

**URL:** https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654
**Category:** Self-hosting
**Tags:** performance, server-resources
**Created:** [December 7, 2017, 11:29pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654 "2017-12-07T23:29:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [December 7, 2017, 11:29pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/1 "2017-12-07T23:29:36Z")

</div>

I’m trying to move ~100 posts to an existing topic.

After a delay of about 10 seconds, it says there was an error when moving posts in a green alert area:

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/3/d33389a75159ae4ca85dcd5014ea1aa28f6f9281.png)

No new entries in `/logs`

No useful information in console either:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/c/bc909dd1c20e74ae8060577f47427ea39ed37003.png)

What can be wrong and where to look for the error?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 7, 2017, 11:36pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/2 "2017-12-07T23:36:52Z")

</div>

Yeah, what this probably means is that you tried to get Discourse to do so much work it had to time out the web worker (which happens after 30 seconds)

We should fix the underlying issue here, moving 100 posts really should not take that long and we can defer a bunch of the work.

* * *

Marking this as a performance #Contribute > Bug

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [December 7, 2017, 11:38pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/3 "2017-12-07T23:38:07Z")

</div>

For now, the work-around would be to move by small portions?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 7, 2017, 11:39pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/4 "2017-12-07T23:39:02Z")

</div>

Yes, absolutely. Your server is stretched anyway from what I can tell.

---

<div class="post-metadata">

### Author: ![Dmitry\_Krasnoperov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_krasnoperov/32/65079_2.png) [@Dmitry\_Krasnoperov](https://meta.discourse.org/u/Dmitry_Krasnoperov)
#### Post date: [September 20, 2019, 6:39pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/5 "2019-09-20T18:39:02Z")

</div>

I’hve just got this error 502 when try to move posts fro one thread to another.

It’s quite repetitive :frowning:

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 21, 2019, 2:19am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/6 "2019-09-21T02:19:50Z")

</div>

How many were you moving?

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [September 22, 2019, 2:25pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/7 "2019-09-22T14:25:10Z")

</div>

happens several times in our case recently, for moving **a single post** to a new topic.

---

<div class="post-metadata">

### Author: ![Dmitry\_Krasnoperov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_krasnoperov/32/65079_2.png) [@Dmitry\_Krasnoperov](https://meta.discourse.org/u/Dmitry_Krasnoperov)
#### Post date: [September 22, 2019, 7:33pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/8 "2019-09-22T19:33:08Z")

</div>

> [@codinghorror](#):
>
> How many were you moving?

I tried several sets from hundreds to tens them single post!  
I can’t find the reason why it doesn’t work sometimes and works just fine in another

---

<div class="post-metadata">

### Author: ![Dmitry\_Krasnoperov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_krasnoperov/32/65079_2.png) [@Dmitry\_Krasnoperov](https://meta.discourse.org/u/Dmitry_Krasnoperov)
#### Post date: [September 24, 2019, 12:01am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/9 "2019-09-24T00:01:32Z")

</div>

> [@Pad\_Pors](#):
>
> happens several times in our case recently, for moving **a single post** to a new topic.

Updated to 2.4.0.beta4 (cb8fa46970) but still experience 502 error on moving 1/5/10/50 messages.  
It brakes administration routine so I can’t tidy up some treads.

---

<div class="post-metadata">

### Author: ![Dmitry\_Krasnoperov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_krasnoperov/32/65079_2.png) [@Dmitry\_Krasnoperov](https://meta.discourse.org/u/Dmitry_Krasnoperov)
#### Post date: [October 7, 2019, 4:28pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/10 "2019-10-07T16:28:47Z")

</div>

Suffers.

Any logs/stat/settings would help?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 8, 2019, 3:36am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/11 "2019-10-08T03:36:55Z")

</div>

@gerhard is this similar to the other reported issue by @Pad_Pors ?

---

<div class="post-metadata">

### Author: ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)
#### Post date: [October 8, 2019, 5:04pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/12 "2019-10-08T17:04:45Z")

</div>

I’m seeing the same thing. Could not find anything relevant in the logs, other than this in /logs:

Error: No Reason Phrase  
Url: https://.no/assets/ember\_jquery-d430881a3fb1403871256e5a02423c4b20a78793685e92088613ca9a701baf88.js

Let me know if there is a way to debug this in a better way.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 8, 2019, 7:16pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/13 "2019-10-08T19:16:03Z")

</div>

I fixed an error that could appear when moving posts into an existing topic which was split in the past. Does this fix the problem you are encountering?

[https://github.com/discourse/discourse/commit/bee000bcec250dc7778a922a4af577e119863f6f](https://github.com/discourse/discourse/commit/bee000bcec250dc7778a922a4af577e119863f6f)

* * *

> [@Pad\_Pors](#):
>
> happens several times in our case recently, for moving **a single post** to a new topic.

Are you sure that it happened when moving to a **new** topic? If so, then that’s a different error than the one I fixed and noticed in our logs.

---

<div class="post-metadata">

### Author: ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)
#### Post date: [October 9, 2019, 7:41am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/14 "2019-10-09T07:41:40Z")

</div>

Unfortunately, I’m still getting 502s with the fix:

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/e/eed0457271166b74676d7c6c7bafb96aa1c25135.png)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 9, 2019, 8:44am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/15 "2019-10-09T08:44:10Z")

</div>

Is there an error in `/logs`? How many posts are you moving? Are you moving the first post of a topic? Are you moving to a new or an existing topic? Is anything out of the ordinary (like whispers, deleted posts or previously split topics) involved?

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [October 9, 2019, 8:46am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/16 "2019-10-09T08:46:34Z")

</div>

yes, (before [a recent update](https://meta.discourse.org/t/can-not-move-any-reply-into-an-existing-topic/129763/8)) we have faced the problem of 502 bad gateway while trying to change replies into a new topic (it did happen randomly and not always).

I’ll report if this still happens.

---

<div class="post-metadata">

### Author: ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)
#### Post date: [October 9, 2019, 9:10am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/17 "2019-10-09T09:10:56Z")

</div>

I’m struggling to find a pattern, unfortunately. it fails when moving one or many posts. Though, I have a hunch it fails most often when moving between two larger topics, which I have a lot of. Many have been split several times. I’ve never used whispers but there are lots of deleted posts in most topics. No smoking-gun errors in /logs :frowning:

edit: I think it started after upgrading to beta5.

---

<div class="post-metadata">

### Author: ![amotl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/amotl/32/109873_2.png) [@amotl](https://meta.discourse.org/u/amotl)
#### Post date: [October 9, 2019, 9:51am UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/18 "2019-10-09T09:51:18Z")

</div>

Hi there,

on [https://community.hiveeyes.org/](https://community.hiveeyes.org/), we recently experienced the same thing when moving posts between topics. While we haven’t investigated further,

> [@DiscourseMetrics](#):
>
> I think it started after upgrading to beta5

If that might help: It was just a single post [1] we wanted to move from a non-public topic into a public one which raised this error. After failing on that, we replicated the post manually.

With kind regards,  
Andreas.

[1] [Pycom Firmware Release 1.20.1 - #9 by clemens - Firmwareschmiede / Firmware development - Hiveeyes](https://community.hiveeyes.org/t/pycom-firmware-release-1-20-1/2605/9)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 9, 2019, 3:17pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/19 "2019-10-09T15:17:32Z")

</div>

Okay, so the **error 500** should be fixed on latest and I just commited [another fix](https://github.com/discourse/discourse/commit/10e509e47f85577e6aa566b3d69c5f5812d35a7a) so that the actual error appears in logs in case there’s another bug in there.

If you get an **error 502** then the moving takes too long and times out. I made lots of changes over the last couple of months to move more metadata when moving posts. I tried to optimized it, but it highly depends on the amount of data and might still be too resource intensive for some server to do all the work in under 30 seconds.  
The solution will be to refactor this one more time and store information about moved posts permanently in the database (instead of a temp table) and do all the heavy lifting in a background job.

---

<div class="post-metadata">

### Author: ![DiscourseMetrics](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursemetrics/32/55756_2.png) [@DiscourseMetrics](https://meta.discourse.org/u/DiscourseMetrics)
#### Post date: [October 9, 2019, 4:33pm UTC](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/20 "2019-10-09T16:33:52Z")

</div>

> [@gerhard](#):
>
> If you get an **error 502** then the moving takes too long and times out.

This seems right as it does take a long time for the request to 502 :slight_smile:

[Next page](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654.md?page=2)
