keepcalculator

06 Numbers and Powers

Self-Host Parse Server on a VPS: Step-by-Step

Card No. 06·30065 · Updated · Standard formula, shown below

This guide walks you through deploying your own Parse Server on a Virtual Private Server (VPS). By the end, you’ll have a self-hosted backend for your mobile or web apps, including the Parse Dashboard for management, all under your control. You’ll need a VPS with Ubuntu 22.04 or 20.04, a domain name (optional but recommended for HTTPS), and basic comfort with the command line.

What You’ll Need

  • A VPS with Ubuntu 20.04 or 22.04 (1 GB RAM minimum, 2 GB recommended)
  • Root or sudo access to the server
  • A domain name pointing to your server’s IP (for SSL)
  • SSH client (Terminal on macOS/Linux, PuTTY on Windows)
  • Node.js 14 or later and npm installed on the VPS
  • MongoDB 4.4 or later (or PostgreSQL) – we’ll install MongoDB

Step-by-Step

  1. Update the system and install dependencies. SSH into your VPS and run:
    sudo apt update && sudo apt upgrade -y
    sudo apt install -y curl git build-essential
  2. Install Node.js and npm. Use the NodeSource repository for a recent version:
    curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
    sudo apt install -y nodejs

    Verify with node -v and npm -v.

  3. Install MongoDB. Import the MongoDB public key and add the repo:
    wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
    sudo apt update
    sudo apt install -y mongodb-org

    Start and enable MongoDB:

    sudo systemctl start mongod
    sudo systemctl enable mongod
  4. Create a project directory and install Parse Server.
    mkdir ~/parse-server && cd ~/parse-server
    npm init -y
    npm install parse-server parse-dashboard
  5. Create a configuration file. Create index.js in the project directory with the following content (replace YOUR_APP_ID, YOUR_MASTER_KEY, and YOUR_DASHBOARD_PASSWORD with strong random strings):
    const ParseServer = require('parse-server').ParseServer;
    const ParseDashboard = require('parse-dashboard');
    
    const server = new ParseServer({
      databaseURI: 'mongodb://localhost:27017/parse',
      cloud: './cloud/main.js',
      appId: 'YOUR_APP_ID',
      masterKey: 'YOUR_MASTER_KEY',
      serverURL: 'http://localhost:1337/parse',
      publicServerURL: 'https://yourdomain.com/parse', // use http if no SSL
    });
    
    const dashboard = new ParseDashboard({
      apps: [{
        serverURL: 'https://yourdomain.com/parse',
        appId: 'YOUR_APP_ID',
        masterKey: 'YOUR_MASTER_KEY',
        appName: 'MyApp',
      }],
      users: [{
        user: 'admin',
        pass: 'YOUR_DASHBOARD_PASSWORD',
      }],
    }, { allowInsecureHTTP: false });
    
    const express = require('express');
    const app = express();
    
    app.use('/parse', server);
    app.use('/dashboard', dashboard);
    
    app.listen(1337, () => {
      console.log('Parse Server running on port 1337.');
    });
  6. Create the cloud code directory. Make a folder named cloud and add an empty main.js file:
    mkdir cloud
    touch cloud/main.js
  7. Test the server. Run node index.js and check that it starts without errors. Open another SSH session and test with:
    curl http://localhost:1337/parse/health

    You should see a JSON response with {"status":"ok"}.

  8. Set up a process manager (PM2). Install PM2 globally and start your server:
    sudo npm install -g pm2
    pm2 start index.js --name parse-server
    pm2 save
    pm2 startup

    The pm2 startup command will output a command to run with sudo; do that to ensure PM2 starts on boot.

  9. Configure a reverse proxy with Nginx (for HTTPS and port 80/443). Install Nginx:
    sudo apt install -y nginx

    Create a config file /etc/nginx/sites-available/parse with:

    server {
        listen 80;
        server_name yourdomain.com;
    
        location /parse {
            proxy_pass http://localhost:1337/parse;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    
        location /dashboard {
            proxy_pass http://localhost:1337/dashboard;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }

    Enable the site and restart Nginx:

    sudo ln -s /etc/nginx/sites-available/parse /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx
  10. Secure with SSL (Let’s Encrypt). Install Certbot:
    sudo apt install -y certbot python3-certbot-nginx
    sudo certbot --nginx -d yourdomain.com

    Follow the prompts. Certbot will auto-renew via a systemd timer.

  11. Update your Parse Server config to use HTTPS. Edit index.js and replace http://localhost:1337 with https://yourdomain.com in both serverURL and the dashboard’s serverURL. Restart PM2:
    pm2 restart parse-server
  12. Test the public endpoints. Visit https://yourdomain.com/parse/health in a browser – you should see the JSON response. Also check https://yourdomain.com/dashboard and log in with your admin credentials.

Common Mistakes

  • Using weak or default keys – always generate strong random strings for appId and masterKey.
  • Forgetting to update the serverURL after adding SSL – the dashboard and client SDKs need the public URL.
  • Not enabling MongoDB to start on boot – it will stop after a reboot.
  • Blocking port 1337 in the firewall – if you use Nginx, you only need ports 80 and 443 open; keep 1337 closed.
  • Running Parse Server as root without PM2 – use a non-root user and PM2 for better security and uptime.

Tips

  • Use a dedicated domain or subdomain for your Parse Server to avoid cookie and CORS issues.
  • Set up regular backups of your MongoDB database using mongodump.
  • Enable MongoDB authentication if your server is public – edit /etc/mongod.conf and create a user.
  • Monitor your server with pm2 monit and set up alerts for high CPU/RAM.
  • Keep your Node.js and Parse Server versions updated to get security patches.

Troubleshooting

  • Health check returns 404: Check that Nginx is proxying correctly – test with curl http://localhost:1337/parse/health on the server. If that works, the issue is Nginx config – check for typos and reload.
  • MongoDB won’t start: Run sudo systemctl status mongod to see errors. Common fixes: ensure the data directory exists and has correct permissions, or check disk space.
  • Dashboard shows “Cannot GET /dashboard”: Ensure you have the dashboard mounted in Express and that Nginx proxies the path. Also check that your browser isn’t caching an old response.
  • SSL certificate fails: Make sure your domain resolves to your server’s IP before running Certbot. Also check that port 80 is open.
  • Parse Server crashes on startup: Look at the PM2 logs (pm2 logs parse-server). Common issues include missing cloud/main.js or incorrect MongoDB URI.

Frequently Asked Questions

Can I use PostgreSQL instead of MongoDB?

Yes, Parse Server supports PostgreSQL as a database. You’ll need to install PostgreSQL and set the databaseURI to something like postgres://user:pass@localhost:5432/parse.

How do I connect my app to this Parse Server?

In your client SDK, set the server URL to https://yourdomain.com/parse and use the same appId and masterKey (masterKey only on the server). For example, in JavaScript: Parse.initialize('YOUR_APP_ID'); Parse.serverURL = 'https://yourdomain.com/parse';

Is it safe to expose the Parse Dashboard publicly?

It’s safer to restrict access via a VPN or IP whitelist. At minimum, use a strong password and enable HTTPS. You can also add basic auth in Nginx.

How do I update Parse Server later?

Stop the server (pm2 stop parse-server), run npm update parse-server in the project directory, then restart with pm2 start parse-server.

Can I run multiple apps on one Parse Server?

Yes, you can configure multiple apps in the dashboard and use different appId and serverURL paths, but each app needs its own database or collection prefix.

What should I do if I forget the master key?

You can change it in the index.js file and restart the server. Clients will need to be updated with the new key.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →