# "There has been an error publishing this post to Discourse."

**URL:** https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844
**Category:** WordPress
**Created:** [2017年十二月27日 21:48 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844 "2017-12-27T21:48:16Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 21:48 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/1 "2017-12-27T21:48:16Z")

</div>

The publishing worked 1 time. Since then I am getting this “There has been an error publishing this post to Discourse.” in Wordpress when trying to update a post with the publish to Discourse box checked.  
I have wordpress 4.9.1, Discourse plugin 1.5.5 (it didn’t work on 1.5.4 either) and latest Discourse installed.

I looked at the log as suggested in another post, i get something like that when trying to publish:  
[27/Dec/2017:21:46:51 +0000] “[chat.example.com](http://chat.example.com)” 172.131.131.131 “POST /posts HTTP/1.1” “WordPress/4.9.1; [https://www.example.com](https://www.example.com)” “-” 403 459 “[https://chat.example.com/posts](https://chat.example.com/posts)” 0.059 0.063 “-”

It seems alright to me…

What else can I do?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 21:54 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/2 "2017-12-27T21:54:49Z")

</div>

Have you set your Discourse username on your WordPress profile page? It needs to match the username that’s used on your Discourse account. That is the most likely cause of the 403 error you are getting. I meant to update the error message for when a 403 error is returned, but forgot to add that to the last update of the plugin.

If you enable the Send Email Notification on Publish Failure setting (found on the wp-discourse Publishing settings tab) you will be emailed a fairly detailed error message if a post fails to publish.

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:11 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/3 "2017-12-27T22:11:30Z")

</div>

Thanks, the username was the issue. But I still have a problem that the comments are not synced even though i created the hook, verified that it is active and has post\_event and that the secret key is the same.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 22:16 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/4 "2017-12-27T22:16:17Z")

</div>

Have you also enabled the hook on WordPress? Do you see any errors when you go to the webhook events list on Discourse? You can access that list by clicking on the Go to events button at the bottom of the webhook edit page.

If it is working properly, comments will not be synced until a new comment is added, or a comment is edited on Discourse.

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:23 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/5 "2017-12-27T22:23:25Z")

</div>

I see proper events on Discourse event list. I updated a comment and immediately got a new event.  
it returned answer:

```
Date: Wed, 27 Dec 2017 22:19:36 GMT
X-Robots-Tag: noindex
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Access-Control-Allow-Headers: Authorization, Content-Type
Allow: POST
Cache-Control: max-age=0
Expires: Wed, 27 Dec 2017 22:19:36 GMT
Vary: User-Agent,Accept-Encoding
Content-Type: application/json; charset=UTF-8
X-Varnish: 55942185
Age: 0
X-Cache: MISS
Accept-Ranges: bytes
Connection: close

```

Also, the meta field wpdc\_sync\_post\_comments of the post is 0 even though there is one comment to the post

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 22:27 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/6 "2017-12-27T22:27:53Z")

</div>

When you click on the Request tab for the event, is it Posting to the correct URL? What is the Status Code for the event?

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:30 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/7 "2017-12-27T22:30:39Z")

</div>

The Request URL look ok. But the X-Discourse-Instance is not, it is http instead of https. does it matter?

```
Request URL: https://www.example.com/wp-json/wp-discourse/v1/update-topic-content
Request method: POST
Accept: */*
Connection: close
Content-Length: 1156
Content-Type: application/json
Host: www.example.com
User-Agent: Discourse/1.9.0.beta17
X-Discourse-Instance: http://chat.example.com
X-Discourse-Event-Id: 32
X-Discourse-Event-Type: post
X-Discourse-Event: post_edited
X-Discourse-Event-Signature: sha256=

```

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:38 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/8 "2017-12-27T22:38:31Z")

</div>

I enabled force https in Discourse, it fixes the url in X-Discourse-Instance but does not solve the sync problem

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 22:39 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/9 "2017-12-27T22:39:07Z")

</div>

What is the status code for the event?

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:40 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/10 "2017-12-27T22:40:21Z")

</div>

all of them are with code 200

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 22:44 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/11 "2017-12-27T22:44:35Z")

</div>

If this is a post that you previously published to another Discourse instance, the topic’s post won’t be found on WordPress. I don’t know if that could be the problem. You could try enabling the wp-discourse Webhook setting ‘Match Old Topics.’ It attempts to match posts to topics by the post title.

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 22:46 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/12 "2017-12-27T22:46:40Z")

</div>

No, it is new.  
when i check the raw comment data on wordpress meta fields i see:

`{"id":22,"posts_count":1,"filtered_posts_count":1,"posts":[],"participants":[{"id":1,"username":"gerald","avatar_template":"https://chat.example.com/user_avatar/chat.example.com/gerald/{size}/7_1.png"}]}`

But the comment text itself does not appear

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2017年十二月27日 23:07 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/13 "2017-12-27T23:07:10Z")

</div>

Maybe this will give a clue, it is the request from events and it says post number = null:

```plaintext
{
  "post": {
    "id": 31,
    "name": null,
    "username": "gerald",
    "avatar_template": "/user_avatar/chat.example.com/gerald/{size}/7_1.png",
    "created_at": "2017-12-27T22:42:02.696Z",
    "cooked": "<p>this is a test comment.</p>",
    "post_number": 2,
    "post_type": 1,
    "updated_at": "2017-12-27T22:42:02.696Z",
    "reply_count": 0,
    **"reply_to_post_number": null,**
    "quote_count": 0,
    "avg_time": null,
    "incoming_link_count": 0,
    "reads": 1,
    "score": 0,
    "yours": false,
    "topic_id": 22,
    "topic_slug": "myslug",
    "topic_title": "my wordpress post title",
    "display_username": null,
    "primary_group_name": null,
    "primary_group_flair_url": null,
    "primary_group_flair_bg_color": null,
    "primary_group_flair_color": null,
    "version": 1,
    "user_title": null,
    "actions_summary": [
      {
        "id": 2,
        "can_act": true
      },
      {
        "id": 5,
        "hidden": true,
        "can_act": true
      },
      {
        "id": 3,
        "can_act": true
      },
      {
        "id": 4,
        "can_act": true
      },
      {
        "id": 8,
        "can_act": true
      },
      {
        "id": 6,
        "can_act": true
      },
      {
        "id": 7,
        "can_act": true
      }
    ],
    "moderator": false,
    "admin": true,
    "staff": true,
    "user_id": 1,
    "hidden": false,
    "hidden_reason_id": null,
    "trust_level": 0,
    "deleted_at": null,
    "user_deleted": false,
    "edit_reason": null,
    "can_view_edit_history": true,
    "wiki": false
  }

```

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2017年十二月27日 23:15 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/14 "2017-12-27T23:15:51Z")

</div>

From looking at your forum/website it seems that you are using a link shortening service. I’m wondering if the redirects that it is making could be causing a problem with either the webhook request or the request that WordPress makes to Discourse to fetch the comment data.

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2018年一月4日 13:29 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/15 "2018-01-04T13:29:53Z")

</div>

I removed the shortening and also removed cache but comments do not appear on wordpress ☹  
Is there anything else i can do?  
\*btw - when enabling “ajax” comments, it overrides the “old commend system” setting so that old comments are always hidden if using ajax

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2018年一月4日 20:36 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/16 "2018-01-04T20:36:09Z")

</div>

Could you try disabling the Sync Comment Data option on the Webhooks tab and see if that makes a difference? There are a couple of things that could be going wrong with updating the comments with a webhook.

When the webhook is not enabled, comments are cached for 10 minutes. For testing purposes, you can change that time period in your theme’s `functions.php` file with some code like this:

```php
add_filter( 'wpdc_comment_sync_period', 'wpdc_custom_comment_sync_period' );
function wpdc_custom_comment_sync_period() {

    return 0;
}

```

> [@gerald](#):
>
> \*btw - when enabling “ajax” comments, it overrides the “old commend system” setting so that old comments are always hidden if using ajax

Thanks for the feedback on that. Loading comments with javascript is an undocumented feature at this point. I’m going to make a few changes to it later this week.

---

<div class="post-metadata">

### Author: ![gerald](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gerald](https://meta.discourse.org/u/gerald)
#### Post date: [2018年一月5日 14:16 UTC](https://meta.discourse.org/t/there-has-been-an-error-publishing-this-post-to-discourse/76844/17 "2018-01-05T14:16:32Z")

</div>

It didn’t change anything when I turned the Sync off.  
It is worth noting that looking at the wordpress meta data, at least some fields are correct:  
discourse\_comments\_count shows the correct number of comments  
discourse\_permalink shows correct url  
Perhaps also worth noting, that before the self hosted Discourse, i did the hosted Discourse trial and then comments synced very well both with and without ajax
