# Random 404 errors when editing posts

**URL:** https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887
**Category:** Bug
**Created:** [October 21, 2020, 3:55pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887 "2020-10-21T15:55:20Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [October 21, 2020, 3:55pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/1 "2020-10-21T15:55:20Z")

</div>

I’ve been getting random 404 errors when editing replies in my forum.

When edits work, they send a PUT request to the endpoint `/posts/:post_id` with a 200 response.

But when they don’t work, I can see in the developer tools a PUT request to `/post_replies/:post_id` that returns a 404. When I refresh the page, the errors go away and I’m able to save the edit correctly (via `/posts/:post_id`, the `:post_id` doesn’t change).

I’m not sure if there is a special condition that could make `/posts` turn into `/post_replies` by mistake or if it’s a different problem. I recently quadrupled my server’s RAM and I haven’t seen anything weird in the logs.

Any help is appreciated.

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [November 10, 2020, 9:55am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/2 "2020-11-10T09:55:34Z")

</div>

I continue to get these random errors when trying to save an edit for other people’s posts. It happens with both old and new posts, but always randomly:

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

And it goes away when I refresh the page and save the edit:

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

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [January 8, 2021, 8:19am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/3 "2021-01-08T08:19:00Z")

</div>

I’m on the latest version and can confirm this is still happening: trying to save an edit on other another user’s post randomly triggers a dialog box with a `not_found` message:

> The requested URL or resource could not be found.

If I reload the page and press the “Save Edit” button again, the error goes away and the edit is saved.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 8, 2021, 7:26pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/4 "2021-01-08T19:26:04Z")

</div>

Those two requests are getting `PUT` to different URLs.

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [January 8, 2021, 7:54pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/5 "2021-01-08T19:54:51Z")

</div>

Right. But why? I’m pressing the same “Save Edit” button in the same post. The only difference is a page refresh

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 8, 2021, 7:57pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/6 "2021-01-08T19:57:49Z")

</div>

Maybe try checking the browser backtrace next time it happens? Since it’s hitting different endpoints it may be going via different methods in the EmberJS app.

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [January 12, 2021, 10:49am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/7 "2021-01-12T10:49:05Z")

</div>

@Falco It just happened again. This is all I see when I open the console after I get the error:

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

And if I try saving again with the console open:

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

Then I refresh the page and it lets me edit:

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

This is the path of the initiator (VM73:1 Script):

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

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [January 22, 2021, 2:25pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/8 "2021-01-22T14:25:47Z")

</div>

I just updated to 2.7.0.beta2 and it’s still happening:

- Try to edit post reply 47994
- PUT `https://mydomain.com/post_replies/47994` =\> 404 The requested URL or resource could not be found. In console: Failed to load resource: the server responded with a status of 404 () `/post_replies/47994:1`
- Reload the page
- Try to edit post reply 47994
- PUT `https://mydomain.com/posts/47994` =\> 200 success

If there’s any other information that would help debug it, I’d be happy to provide it.

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [February 9, 2021, 8:44am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/9 "2021-02-09T08:44:54Z")

</div>

This happened 3 times today in less than an hour 😅

Is there anything else I could do to help track this bug down?

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [March 23, 2021, 7:29am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/10 "2021-03-23T07:29:32Z")

</div>

@Falco I finally figured out how to consistently reproduce this bug:

1. Disable `enable filtered replies view`
2. Click on the arrow on a reply: ![image](https://global.discourse-cdn.com/meta/original/3X/d/b/db725359d31cb473fc4cd2c32797372485ac0546.png)
3. Click on the arrow to jump to the original message: ![image](https://global.discourse-cdn.com/meta/original/3X/2/e/2e209390a10ffe84329fa5c9f1fb429b6348211c.png)
4. Click on the edit icon: ![image](https://global.discourse-cdn.com/meta/original/3X/5/3/53ee19f744bf0acecca28de26aec470892e211bd.png)
5. Make a change and hit “Save changes”. You’ll get a dialog box saying that the URL or resource wasn’t found (404).

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [March 24, 2021, 1:50pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/12 "2021-03-24T13:50:43Z")

</div>

Thanks @Nacho_Caballero, the specific steps were very helpful. I have a PR up with a fix: [FIX: 404 error when editing an expanded reply by pmusaraj · Pull Request #12504 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/12504)

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [March 24, 2021, 2:27pm UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/13 "2021-03-24T14:27:46Z")

</div>

No problem! Such an easy fix 😅

---

<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: [March 25, 2021, 5:07am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/14 "2021-03-25T05:07:54Z")

</div>



---

<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: [April 7, 2021, 12:15am UTC](https://meta.discourse.org/t/random-404-errors-when-editing-posts/167887/15 "2021-04-07T00:15:34Z")

</div>

As usual thank you for your patience with us Nacho – when you provide very detailed repros we can almost always whip up a fix!
