Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Parse.com: Setting up the Open Source Parse API Server

Parse.com: Setting up the Open Source Parse API Server

37

Following Parse’s announcement of the service winding down and the subsequent release of the Parse API Server, I’ve taken the time to setup my own instance of the open-source software to help migrate from Parse.com before it shuts down in January 2017.

Prerequisites

If you’re setting up Parse Server on your server or local machine, you need to make sure the following packages are installed:

  • NodeJS v4.1+ (tested with v4.2.6)
  • MongoDB version v2.6.x or v3.0.x (tested with v3.0.9)
  • Python 2.x (tested with v2.7.6)

Setting up Node Modules

Decide on where you want your Parse API server to live on your server. For the purpose of this guide, I’m using the location /var/www/parse/. Start by installing the following Node packages using npm:

Note: If you have trouble installing the above packages, you may need to make sure you have the required dependencies installed. For example, installing the libkrb5-dev library, using the following command line on Ubuntu:

sudo apt-get install libkrb5-dev

Setting up Parse Server

Once the packages are installed, we create a Express App to mount the Parse API at a specified path. I created the file app.js within the /var/www/parse/ folder (this folder should now contain a folder called node_modules) and copied and pasted in the below code:

You will need to change the databaseURI setting (line 9) to point to your MongoDB instance.

Remember to change the appId and masterKey settings (line 10-11) in the above file to reflect your application. If you want to use a different path or port, you can change those too in the above code. By default, the API will be served on the /parse URL (e.g. https://localhost/parse), using port 1377.

Running the Parse Server

Once everything has been setup, you can start the Parse API server by running node app.js from the installed folder. If everything works correctly, you’ll see something like:

Run-ParseServer-app

Then, if you visit your server URL, e.g. https://localhost:1377/parse, you should see the Parse API server running:

ParseServer-Chrome

I know what you’re thinking… It may look like an error message, but it means the Parse API server is working. Now you can confirm it by following the verification steps below.

Verification

You can also verify that the Parse API Server is running correctly by using some cURL commands. For example, you can issue the following two commands to save and retrieve data:

Amazom AMI

I have also created a Amazon Machine Image (AMI) on AWS with everything already setup and ready to go. You can follow this AWS Guide to add my AMI.

The AMI Name is: Parse-Server (located in Europe Ireland)

deploy-to-aws

Bugs and Issues

The Parse API Server was only recently released and may not work exactly as the Parse.com service works. If you encounter issues with using the server, you can post your issues and bugs on the Issue Tracker.

For anything else, feel free to post a comment below.

Amazon Web Services, AMI, MongoDB, NodeJS, Open Source, Parse, Tutorial

37 comments on “Parse.com: Setting up the Open Source Parse API Server”

  1. AWS: Install NodeJS 4.x or 5.x on Ubuntu 14 | Web Niraj says:
    February 1, 2016 at 10:22 AM

    […] you are looking to install the Parse API Server on your Ubuntu machine, make sure you install […]

    Reply
  2. Angel Sosa says:
    February 1, 2016 at 1:34 PM

    Thanks to the tutorial, Coulnd find the AMI Name: Parse-Server.

    Reply
    • Niraj Shah says:
      February 1, 2016 at 2:09 PM

      Sorry, I forgot to mention that AMI is located in Europe Ireland, but you can then copy to any region.

      Reply
  3. dp says:
    February 1, 2016 at 1:50 PM

    I got the same unauthorized error..does that mean it is running though?!

    Reply
    • Niraj Shah says:
      February 1, 2016 at 10:52 PM

      Yep, if you’re seeing {"error":"unauthorized"} when visiting the API via a browser, it means its working. If you call it using your API Key or the verification code I’ve posted, it will return success / failure as the Parse API does.

      Reply
      • dp says:
        February 2, 2016 at 5:49 AM

        Hi Niraj, Thank you for your reply. Really Really appreciate it. I am so devastated because I have zero knowledge about node.js and mongo db. After a few hours of studying, I got some basic concepts now.
        However, from my understanding, the following code in index.js will write that log when visiting “localhost/parse”? Please advice me if I am wrong.

        var port = process.env.PORT || 1337;
        app.listen(port, function() {
        console.log(‘parse-server-example running on port ‘ + port + ‘.’);
        });

        In addition, when running parse server, I got the following saying DATABASE_URI not specified but I did provide it to my local mongo URI (databaseURI: ‘mongodb://localhost:27017/dev’)? Again, Probably I am wrong. Please share your thoughts on this!! Many thanks in advance.

        > node index.js

        DATABASE_URI not specified, falling back to localhost.
        parse-server-example running on port 1337.

      • Niraj Shah says:
        February 2, 2016 at 9:20 AM

        The code you’re referring to will print to the console when you run the script, not when visiting the URL. My tutorial has a screenshot you what you’ll see when visiting the web page, and when running the script.

        Did you use the code from my tutorial to setup the script, or did you use another source? The error suggest that the parameter is not correctly set.

  4. Angel Sosa says:
    February 2, 2016 at 2:46 AM

    @Niraj Shah, I deployed the AMI but Im having problems when I try to run the Parse server with node app.js. This is the error on the terminal::::

    ubuntu@ip-172-31-30-19:~$ node app.js
    module.js:328
    throw err;
    ^

    Error: Cannot find module ‘/home/ubuntu/app.js’
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
    ubuntu@ip-172-31-30-19:~$

    What should I do?
    Thanks

    Reply
  5. Angel Sosa says:
    February 2, 2016 at 2:50 AM

    @Niraj Shah, never mind, forgot access the path: /var/www/parse/

    Reply
    • Niraj Shah says:
      February 2, 2016 at 9:11 AM

      Glad you got it working. You are free to move the app.js file and the node_modules folder to any location you want, it will still work.

      Reply
  6. AWS: Install MongoDB 3.x on Ubuntu 14 | Web Niraj says:
    February 2, 2016 at 9:00 AM

    […] If you’re running the default Ubuntu 14 LTS server on AWS, you’ll find that the package manage will only install MongoDB v2.x. However, you can install the latest version by updating apt-get using this tutorial, allowing you to use install the Parse API Server. […]

    Reply
  7. Angel Sosa says:
    February 2, 2016 at 1:27 PM

    @Niraj Shah, thanks for your support men. How do I test the deploy using AWS. Me as @dp have zero knowledge of working under this environments. How do I test the severs if I have everything running on AWS with the AMI?

    Reply
    • Niraj Shah says:
      February 2, 2016 at 2:07 PM

      Follow the verification setups in my tutorial to test your AWS setup. Instead of using the localhost in http://localhost:1337/parse, use the IP address of your AWS server so you can access it from your PC, e.g. http://your_aws_ip}:1337/parse. As long as you are running the script using the command node app.js, the server is working.

      You can also visit: http://{your_aws_ip}:1337/parse in a browser to test that it works (replacing {your_aws_ip} with your server IP address).

      Reply
  8. Angel Sosa says:
    February 2, 2016 at 2:09 PM

    Thats, exactly what I did last night, but did not work… I wont if I have todo any other install on the AMI instance.

    Reply
    • Niraj Shah says:
      February 2, 2016 at 2:38 PM

      You need to give me more details about what doesn’t exactly work? Do you get a error message? does the page fail to load? Post the error message or share a screenshot of what you see. AWS Instances are protected my firewalls by default, so you may need to open up access to port 1337 (or all ports if its easier). See the AWS EC2 Help Section to learn how to edit the firewall settings.

      Reply
  9. Geraldo says:
    February 3, 2016 at 7:02 PM

    Hello, I followed this post, I think is everything is running, but when I try access http://52.27.220.189:1337/myparse I got ERR_CONNECTION_TIMED_OUT.

    Do you know what I can do to fix this?

    Reply
    • Niraj Shah says:
      February 14, 2016 at 5:31 PM

      Have you opened up port 1337 on your firewall? By default it’s blocked, so you’ll need to allow access.

      Reply
  10. Peter says:
    February 12, 2016 at 9:48 PM

    Thanks for this Niraj, I think that I have the AMI installed, I have the security groups set for port 80 and safari is saying that it can’t connect to the server. via ssh I followed the rest of your guide and it says that Parse Server is running on port 1377. Also, how do I find the mongoldb URI if I installed your AMI? If you have any input on these id appreciate the help.

    Reply
    • Peter says:
      February 13, 2016 at 9:18 PM

      Ok, I have the Server showing that “error” in the browser. Forgive me, as I like others that were using Parse know little to nothing about this backend stuff. while using ssh and typing node app.js it starts the purse server and I am able to get that error message. the command line doesn’t allow me to enter any commands at this point. and if I ctrl-c to get a prompt back then I can’t get the error message anymore. So how do I enter the curl commands that you are referencing in your post to test the server?

      Reply
      • Niraj Shah says:
        February 14, 2016 at 5:36 PM

        OK, the error message means it’s working. To run the cURL commands, you should use a second terminal window to input these in. Using Ctrl-C on the window running the app will always shutdown the Parse server. What I do is use 2 terminal windows: (1) to run the Parse Server, (2) to run the cURL command lines or access MongoDB to verify data has been correctly saved.

    • Niraj Shah says:
      February 14, 2016 at 5:34 PM

      You also need to make sure port 1337 is allowed via the firewall too. The script I’ve created on the AMI already has the correct MongoDB URL set: mongodb://localhost:27017/myapp. You just need to change the myapp part to reflect the name of your app.

      Reply
  11. Peter says:
    February 17, 2016 at 9:57 PM

    Ive made lots of progress thanks to this post and AMI. One more question would be updating. How do I go about updating this parse server to the most recent version of parse server?

    Reply
    • Niraj Shah says:
      February 19, 2016 at 12:51 PM

      From the /var/www/parse directory, you can run npm update parse-server to update to the latest version of Parse Server. Pretty easy!

      Reply
  12. Abhijeet Kulkarni says:
    March 3, 2016 at 6:53 AM

    How do i access cloud code ?

    i tried using following curl

    curl -X POST
    -H “X-Parse-Application-Id: appid”
    -H “Content-Type: application/json”
    -d ‘{}’
    localhost:1377/parse/functions/hello

    but got error {“code”:141,”error”:”Invalid function.”}.

    Please help

    Reply
    • Niraj Shah says:
      March 3, 2016 at 9:04 AM

      Before you can use Cloud Code, you’ll need to update the ParseServer setup in app.js. Add a line like:

      var api = new ParseServer({
        ...
        cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
        ...
      });

      And remember to change the path to match the exact location. Then, the command you used above should work.

      Reply
      • Abhijeet Kulkarni says:
        March 7, 2016 at 8:16 AM

        Thank you,it is working now.

      • Abhijeet Kulkarni says:
        March 7, 2016 at 8:22 AM

        Thanks @Niraj Shah.

        One question i have is if i update contents of main.js that do not gets reflected untill i restart the server,but on Parse.com there was no such need to do it.
        How this can be automated?

      • Niraj Shah says:
        March 7, 2016 at 10:47 AM

        Parse.com probably did restart your app when your cloud code was updated, but it was likely hidden from the user. Depending on how you deploy the code to the server, you can most likely setup a hook to detect changes to main.js and restart accordingly (i.e. a git or svn hook when code is updated).

      • Abhijeet Kulkarni says:
        March 7, 2016 at 11:43 AM

        I am not aware about this hook. Can you please provide some link where i can get example for this or can you provide sample example for this?

      • Niraj Shah says:
        March 7, 2016 at 12:51 PM

        This isn’t specific to Parse. Google svn hooks or git hooks for information on how to setup hooks. You can also take a look at the Node watch module for a different approach.

      • Abhijeet Kulkarni says:
        March 7, 2016 at 1:16 PM

        Okay I will look for this.Thanks for quick reply.It helped 🙂

  13. fiqri says:
    March 16, 2016 at 5:29 AM

    hi niraj, thanks for the article but i want to ask you :

    1. where i can get this ??

    appId: ‘{YOUR_APP_ID}’,
    masterKey: ‘{YOUR_APP_MASTER_KEY}’,
    fileKey: ‘optionalFileKey’

    i clone the source parse.com from their github but i confused to get appid, masterkey and filekey ?

    Reply
    • Niraj Shah says:
      March 20, 2016 at 6:07 PM

      You get the appId and masterKey from your existing Parse.com app (see App Settings), or you just make it up if you don’t have a previous app.

      Reply
  14. Simon Lehmann says:
    April 4, 2016 at 1:17 PM

    Hi, Great tutorial,

    Is it possible to set up the Parse server with some kind of high availability? I have seen PM2 being used but it looks pretty complicated.

    Thanks

    Reply
    • Niraj Shah says:
      April 4, 2016 at 4:27 PM

      I would recommend use of pm2, but it’s quite easy to get started. It’s can get complicated if you are trying to achieve something complex, but for now you can start with:

      pm2 start app.js

      Reply
  15. Harshad says:
    September 15, 2016 at 4:24 PM

    Hello @niraj,

    i got {“error”:”unauthorized”} response, but when i try curl example i get response saying, connection refused by server.
    can you help me ?

    Reply
    • Niraj Shah says:
      September 15, 2016 at 4:48 PM

      You need to make sure the appId and masterKey are the same in your app and server. Edit the app.js file as per my tutorial.

      Reply

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bash Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Geolocation Google Nexus 5 Hacking HTML5 Input Sanitization iOS JavaScript jQuery Laravel 5 Laravel 5.2 Linux Mac OS NodeJS Parse PDF PHP Plugin Portfolio Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy