# Cannot connect WP Discourse to Discourse forum

**URL:** https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119
**Category:** WordPress
**Created:** [05.Октябрь.2016 14:03:01 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119 "2016-10-05T14:03:01Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Optiroot](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@Optiroot](https://meta.discourse.org/u/Optiroot)
#### Post date: [05.Октябрь.2016 14:03:01 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/1 "2016-10-05T14:03:01Z")

</div>

Hello. I need some help, I’m working on this from yesterday but I can’t figure out what is the problem.

In brief, I had a Blog built with Wordpress connected to Discourse, so every post published in Wordpress would create a new discussion in the forum. The **SSO** wasn’t enabled.

Then, one week ago, I enabled the HTTPS to the Discourse forum. It works very well and no problem for the certificate, but WordPress now doesn’t want to connect.

The URL is right. I tried with http, https and without “http”, but nothing.  
The API key is right, I tried re-generating it. Nothing.  
The username is _system_, which is the default and it is present in my Discourse installation.

Tried about everything. But it doesn’t want to connect. It shows:  
`You are not connected to a Discourse forum. Please check your settings for 'Discourse URL', 'API Key', and 'Publishing username' Also, make sure that your Discourse forum is online.`

Any ideas on this?

---

<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: [05.Октябрь.2016 16:37:49 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/2 "2016-10-05T16:37:49Z")

</div>

Is your blog also using https?

---

<div class="post-metadata">

### Author: ![Optiroot](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@Optiroot](https://meta.discourse.org/u/Optiroot)
#### Post date: [05.Октябрь.2016 16:49:19 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/3 "2016-10-05T16:49:19Z")

</div>

Yes, it is.

Both are using https, same certificate (wildcard subdomain) but different servers. Blog in a server of my country and Discourse in Digital Ocean.

---

<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: [05.Октябрь.2016 19:55:29 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/4 "2016-10-05T19:55:29Z")

</div>

Yes, I’m seeing the same problem with https setup through Let’s Encrypt on both my WordPress site and my forum. The error I’m getting on the WordPress site is ‘Too many redirects’.

---

<div class="post-metadata">

### Author: ![Optiroot](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@Optiroot](https://meta.discourse.org/u/Optiroot)
#### Post date: [06.Октябрь.2016 08:31:54 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/5 "2016-10-06T08:31:54Z")

</div>

I have a Comodo Wildcard Subdomain certificate but I don’t get any “too many redirects” errors. Maybe you misconfiguerd the installation of https in WordPress?

I don’t get any errors, just that is about that my discourse forum doesn’t exist…

---

<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: [06.Октябрь.2016 13:36:12 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/6 "2016-10-06T13:36:12Z")

</div>

I am getting a ‘too many redirects’ error as the result of the function that makes the API call to Discourse.

---

<div class="post-metadata">

### Author: ![Optiroot](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@Optiroot](https://meta.discourse.org/u/Optiroot)
#### Post date: [06.Октябрь.2016 15:37:24 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/7 "2016-10-06T15:37:24Z")

</div>

But are you using the SSO feature? Because I don’t have this error…

I don’t know how to fix this.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [06.Октябрь.2016 17:31:02 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/8 "2016-10-06T17:31:02Z")

</div>

Do you have ssh access at both ends?

If so can each box see the other via their HTTPS addresses?

```
curl -Is https://meta.discourse.org | head -1

```

Do you get the HTTP/1.1 200 OK response?

---

<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: [06.Октябрь.2016 17:41:32 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/9 "2016-10-06T17:41:32Z")

</div>

Yes, when the initial request is made from the server hosting the WordPress site with curl, it returns `200`. The plugin uses `wp_remote_get` to make the request. When the request is made with `wp_remote_get` it is returning the `'too many redirects'` error. This is with the server hosting the WordPress site running Ubuntu 16.04.1.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [06.Октябрь.2016 17:42:38 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/10 "2016-10-06T17:42:38Z")

</div>

Ok, so you can cURL from both hosts to one another?

---

<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: [06.Октябрь.2016 23:12:18 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/11 "2016-10-06T23:12:18Z")

</div>

I think that the problem has to do with the server configuration for the host of your WordPress site. You could probably confirm that by installing the [query monitor](https://en-ca.wordpress.org/plugins/query-monitor/) plugin on your site. After doing that, go to the Discourse options page and refresh it. You will probably see something like this:

 ![](https://global.discourse-cdn.com/meta/original/3X/7/8/78821d8a75c2092cf7e146ff969f0577ff972c6c.png)

Click on the orange box and then look at the results under ‘HTTP Requests’. The result should look something like this (I’ve deleted my api-key from the image):

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

This is the result that I have been getting using the DigitalOcean 1 click install of WordPress with their letsencrypt setup for ssl.

I’d really like to figure out how to configure it so that so that the DigitalOcean 1 click WordPress install will work with https with the wp-discourse plugin. I’m not sure what the problem is.

For now, for setting up a WordPress site on DigitalOcean with https enabled, follow this guide (with the letsencrypt option.) [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04). This is working with both WordPress and Discourse setup on DigitalOcean with letsencrypt.

I’ll look at this some more later to try to find what the problem is that is causing the redirects. Maybe you could contact the host of your WordPress site and see if they have any ideas.

---

<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: [07.Октябрь.2016 00:34:10 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/12 "2016-10-07T00:34:10Z")

</div>

If it is requesting `http://` isn’t the problem that it should be requesting `https://` instead? Where is it redirecting _to_, exactly?

---

<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: [07.Октябрь.2016 00:57:29 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/13 "2016-10-07T00:57:29Z")

</div>

It seems to be redirecting to itself (the request was made from this page):  
`[Thu Oct 06 20:20:16.877097 2016] [:error] [pid 1658] [client 96.54.191.49:50791] Too many redirects, referer: https://simonscrap.com/wp-admin/admin.php?page=wp_discourse_options&tab=publishing_options`

There are a few references on the web to redirect loops with ssl enabled in the WordPress admin, but nothing that I can follow that explains what’s going on. I now have a configuration that works and one that doesn’t, so it should be easier to see what’s happening.

---

<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: [07.Октябрь.2016 07:18:59 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/14 "2016-10-07T07:18:59Z")

</div>

From what I can figure out (this took a while), this is what’s causing the error:

It’s redirecting to Discourse. The plugin function that tests the connection to Discourse makes a request to `GET /users/system.json` when the settings page is saved. TheWordPress function `wp_remote_get` is used to make the request. It is set to follow a maximum of 5 redirections (that’s the default.) When HTTPS is enabled on the Discourse site, each time the function is run, it makes 5 requests to Discourse. Each request returns a `301` and a `549` status code. After five requests, the `wp_remote_get` function returns the ‘too many redirects’ error to WordPress. I don’t know why Discourse is returning the `549` status code.

Increasing the value for the allowable number of redirects just causes more requests to be made, but eventually results in the same error.

When HTTPS is not enabled on Discourse, everything runs fine.

The solution that working for me on the DigitalOcean setup is to install the `php-curl` extension and restart the server. Doing this makes the DigitalOcean 1 click WordPress install work with HTTPS enabled on both WordPress and Discourse. After enabling `php-curl` the request to Discourse is returning `200` and `2045`.

It looks like what is going on is that the WordPress HTTP API functions (they are used throughout the plugin for making API calls to Discourse) have a function called `_get_first_available_transport` that first tries to use `curl` but falls back to `streams` if `curl` isn’t available.

---

<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: [07.Октябрь.2016 07:23:58 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/15 "2016-10-07T07:23:58Z")

</div>

Can you check to see if `php-curl` is installed on your server?

---

<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: [07.Октябрь.2016 18:13:58 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/16 "2016-10-07T18:13:58Z")

</div>

Wow great detective work Simon! 🔍

Do we know why it’s returning 301 and 549? 301 is “moved permanently”, but I can’t find 549 anywhere as a valid HTTP status code, or in our codebase.

---

<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: [07.Октябрь.2016 22:47:23 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/17 "2016-10-07T22:47:23Z")

</div>

Yeah, I was reading the nginx access log incorrectly. 301 is the status code, the number after that (549) is the number of bytes sent.

---

<div class="post-metadata">

### Author: ![blau](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blau/32/34145_2.png) [@blau](https://meta.discourse.org/u/blau)
#### Post date: [11.Январь.2017 20:09:51 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/18 "2017-01-11T20:09:51Z")

</div>

Wordpress and Discourse on https. Installing `php5-curl` resolved the issue for me, thank you!

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [20.Май.2018 22:48:28 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/19 "2018-05-20T22:48:28Z")

</div>

CURL is already installed on my server. But i’ve same problem after using https on my blog and forum. Different SSL certificate is problem for [WP Discourse](https://github.com/discourse/wp-discourse).

`wp-json/wp-discourse/v1/update-topic-content` works fine.

`/wp-json/wp-discourse/v1/update-user` 404 error.

---

<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: [20.Май.2018 23:51:03 UTC](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119/20 "2018-05-20T23:51:03Z")

</div>

> [@bekircem](#):
>
> `wp-json/wp-discourse/v1/update-topic-content` works fine.
> 
> `/wp-json/wp-discourse/v1/update-user` 404 error.

The update-user route is only initialized on WordPress if you have enabled the SSO Provider option. If you haven’t enable the SSO Provider option, then returning a `404` error is the correct response. From the option’s description:

> This setting will only be activated if your site is functioning as the SSO provider for Discourse (this can be overridden by hooking into the ‘wpdc\_use\_discourse\_user\_webhook’ filter.)

The update-user webhook was added to the plugin before the Create or Sync Discourse Users on Login option was added (that option is found on the SSO Provider options tab.) The Create or Sync Discourse Users on Login option is probably more useful for most cases.

If you have enabled the SSO Provider option and the Update Userdata webhook and you are still getting a `404` error, please let me know and I’ll look into it.

[Next page](https://meta.discourse.org/t/cannot-connect-wp-discourse-to-discourse-forum/51119.md?page=2)
