Can't connect expo to Parse Server

We’re able to connect React and even React Native (using a simulator) to Parse Server, but have not been able to connect an exp application to it. When we attempt to login into the Parse Server using the following settings:

import React from ‘react’;
import { Provider } from ‘react-redux’;

import RootNavigation from ‘./src/stackNav/views/RootNavigation’;
import store from ‘./src/store’;
import Parse from ‘parse/react-native’;

export default class SampleNavigation extends React.Component {

    componentWillMount() {
      Parse.initialize('myAppId', 'myJavascriptKey');
      Parse.serverURL = 'http://localhost:1337/parse';
    }
     
    render() {
      return (
        <Provider store={store}>
          <RootNavigation />
        </Provider>
      );
    }

}

Expo.registerRootComponent(SampleNavigation);

But I’m continually receiving the same error message:

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

Please let me know if there is any special settings required by expo.

Thanks, Norman

are you running this on your phone?

If you are running Parse on your computer and trying to connect to it on your phone, you need to put your specific IP address in – localhost will refer to the phone if you are on the phone.

Plz did you find any solution? I have the same problem

what do you guys think about Back4app as
the best Parse Alternative for developing scalable and
extensible applications? Is anyone using the platform?

if you are running on the phone then change your localhost with the IP of your desktop

to get you desktop ip

If both your desktop and phone are connected to the same WiFi (or any other local network), then use your desktop IP address assigned by the router (not localhost and not 127.0.0.1 ).

To find out the IP address of your desktop:

  • type into the command line ipconfig (Windows) or ifconfig (Unix)
    • on Linux the one-liner ifconfig | grep "inet " | grep -v 127.0.0.1 will yield only the important stuff
    • there’s a bunch of suggestions on how to have a similar output on Windows
  • there’s going to be a bunch of IP’s
  • try all of them (except the forementioned localhost and 127.0.0.1 )

If your phone is connected to the mobile network , then things are going to be harder.

Either go hardcore:

  • first find out your router external IP address (myip - Google Search)
  • then, on the router, forward some port to <your desktop IP>:<server port number>
  • finally use the external IP address and forwarded port