Disqus, WordPress and Azure Web Apps – “Unable to connect to the Disqus API servers”

Having used Disqus on other sites, I wanted to add it on my blog as the comments system.

I am using WordPress/Project Nami on Azure Web Apps and had some issues getting Disqus setup.

Upon activating the WordPress plugin and following the Disqus documentation, the configuration wizard would fail with the error “Unable to connect to the Disqus API servers”.

Inside the function wp-content\plugins\disqus-comment-system\lib\api\disqus\url.php on line 55 there is a CURL call to fetch information from Disqus, which was failing on certificate/https validation.

I was able to workaround the issue by undertaking these steps –

  1. Download the cacert.pem file manually from https://curl.haxx.se/docs/caextract.html and place it in the lib\api\disqus\ folder

    (Tip – you can use Kudu with Azure Apps to easily upload the file – http://www.jamessturtevant.com/posts/How-to-add-edit-and-remove-files-in-your-azure-webapp-using-the-kudu-service-dashboard/)

  2. Around Line 55 in the api\disqus\url.php file add the following to the $c_options array
    CURLOPT_CAINFO => __DIR__ .’/cacert.pem’

    (You can edit using Kudu, but I edited this file using the new App Service Editor feature from the Azure portal as I wanted to try it out. The App Service Editor is a web based IDE based on the Monaco code editor which ships with Visual Studio Code)appservice

    Don’t forget the comma at the end of the existing CURLOPT_TIMEOUT => SOCKET_TIMEOUT – I’m not a dev guy so this caught me out initially!


Hopefully if you are suffering the “Unable to connect to the Disqus API servers” error this will help. I’m not sure if this is specific to Azure Web Apps or other web hosts too.