Connection to a Full Sync Realm returns 400 Bad Request

Hello there,

I’m trying to develop a simple script that connects to my Realm Object Server instance in Realm Cloud, but I keep getting the error:

ERROR: Connection[1]: Websocket: Expected HTTP response 101 Switching Protocols, but received:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 14
Content-Type: application/json; charset=utf-8
Date: Wed, 05 Feb 2020 14:41:55 GMT
ETag: W/"e-G3695v1YRbW4oX5T4IAWdmV3xMI"
X-Powered-By: Express

Connection[1]: Connection closed due to error
{ message: 'Operation canceled', errorCode: 1 }

The authentication is performed successfully, and the Realm is created (I checked in Realm Studio), but when it comes to open the Realm, this error is returned.

Here is my code:

const Realm = require('realm');
const schema = [
    name: 'Car',
    properties: {
      make:  'string',
      model: 'string',
      miles: {type: 'int', default: 0},
    name: 'Person',
    properties: {
      name:     'string',
      birthday: 'date',
      cars:     'Car[]', // list of cars
      picture:  'data?'  // optional property

const main = async () => {
  const config = {
    url: '',
    realm: 'realms://',
    file: 'realm/development.realm',

  const createUser = true;
  const username = 'test-user';
  const password = 'test-password';
  const fullSynchronization = true;

  const credentials = Realm.Sync.Credentials.usernamePassword(
    username, password, createUser,

    createUser, username, password,

  try {
    const user = await Realm.Sync.User.login(config.url, credentials);
    console.log(`User ${username} logged in successfully!`);

    const realmConfig = user.createConfiguration({
      sync: {
        url: config.realm,
      path: config.path,

    const realm = await;

    console.log(`Connected to Realm successfully!`);
  } catch (e) {



Thanks for the help!

I realized that I was authenticating in another server (domain, while the correct was to use But thanks anyway!