parse-server: 'Unable to connect to Parse API' since enabling HTTPS

We’ve added SSL to our AWS-hosted ParseServer, but are receiving this error when running any CloudFunction:

"error": {
    "code": 100,
    "message": "XMLHttpRequest failed: \"Unable to connect to the Parse API\""
  }

We’ve updated our serverUrl to have https. After a bit of digging around, I ran into ParseServer/middlewares.js#handleParseHeaders, where I logged the req.protocol. It says the protocol is http, even though the requests are sent with https.

Just for more info - we have not yet enabled SSL on the mongolabs database. GET requests work fine.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 36 (11 by maintainers)

Most upvoted comments

I have fixed this issue. Reason behind this is that node rejects unauthorized TLS. so just put process.env.NODE_TLS_REJECT_UNAUTHORIZED = “0”;

in my parse server instance file.

The serverURL is used in cloud code, it should 99% of the time be http://localhost:[port]/[mountPath].

If you’re using https in node, i recommend you start a http sever as well listening on any different port from the https server and pass the host parameter to 127.0.0.1. This will allow communications only from the server itself.

In case anyone is still having this issue, I had the same and managed to fix by changing my Server URL from https://myapp.com/parse to https://www.myapp.com/parse

I am using self hosted parse-server and not able to use cloud functions since I have enabled HTTPS, if I revert it back to HTTP it works as expected.

Also he problem is only with those cloud function which have Parse.Query, if i create a function simply return “Hello” as response it works on both HTTP and HTTPS.

I am getting following error message when run a cloud function which have Parse.Query code.

{ “code”: 141, “error”: “XMLHttpRequest failed: "Unable to connect to the Parse API"–100”}

can anyone tell me how can I fix this?

Here is what worked for me:

Environment: app deployed on AWS, with the load balancer configured for HTTPS

On the server side, where you configure parse-server, use HTTP in the serverURL configuration parameter. On the client side, use HTTPS when you initialize the Parse app/library.

My theory is that the load balancer is terminating HTTPS traffic, so from the load balancer to the instance, it might be HTTP traffic. In this case, if the parse-server is configured for a HTTPS URL, then it might be trying to listen on a different port or something screwy like that?

I’m not an expert on how the AWS architecture works under the hood, so my rationale might be way off or downright incorrect. If anyone can explain why this would work, please chime in.

+1 Only the parse cloud code cannot connect to the server via https…

Just had this issue. For me the problem was solved by replacing cert.pem with fullchain.pem certificate (both from Let’s Encrypt) in https server options. I found the issue by running wget https://mypublicdomain.com:1337/parse which surprisingly returned ERROR: cannot verify mypublicdomain.com's certificate even though web browser didn’t have any problem. Solution was inspired by https://github.com/certbot/certbot/issues/2026