Deployment

Overview

This guide will teach you how to deploy your server to a hosting service of your choice.

Important

The completion of Production Environment Setup is required to continue.

Heroku

Login or sign-up to Heroku and configure your app:

Create a new app from the top menu and set your app name and preferred region where the server is hosted:

Deploy your by connecting via Github or using the Heroku CLI. This will import your code to heroku and will automatically rebuild your app when changes are pushed to your repo.

As a final step you need to set your environment variables.

Navigate to "Settings" and reveal the keys. Here you can paste all the variables from your .env file. Make sure that these variables are production-ready (no references to localhost, and different database that used in local development)

Make sure to update SERVER_URL in the config vars to the deployed url on Heroku. This looks something like moralis-demo.herokuapp.com/server. Also make sure to set this same serverUrl in your frontend.

You are now self-hosting your own Moralis Server!

AWS Elastic Beanstalk

Prerequisites

One-click deployment

Be aware that this process could resort to expenses as Elastic Beanstalk is not part of AWS Free Tier.

Click here to deploy automatically and follow the instructions below:

Scroll down leaving all the other settings as default and choose Upload your code:

Public S3 URL should be automatically selected and filled. Make sure it is so and choose Review and launch:

Scroll down leaving all the settings as default and choose Create app:

After a couple minutes the application is created but the environment is not ready because you need to set your environment variables:

In the left navigation pane, go to Configuration and at the row where we find Environment properties, choose Edit:

Paste the environment variables retrieved on the previous steps to the corresponding fields (marked in green) and choose Apply:

This video also shows you how to get the environment variables.

Elastic Beanstalk will update your environment and after a couple of minutes it will be ready:

In the left navigation pane, choose Go to environment to test it:

Add /server to the URL and you'll be accessing your Moralis Parse Server hosted on AWS Elastic Beanstalk:

You are now self-hosting your own Moralis Server!

Railway

One-click deployment

Click here to deploy automatically.

This will also create a MongoDB and Redis instance for you automatically, all managed by Railway. If you are using your own MongoDB/Redis instances, you can follow Manual Deployment, or use this template and just delete the MongoDB and Redis services later.

  1. After your server has deployed, assign it a domain (see Step 4 of Manual Deployment).

  2. Copy your MongoDB and Parse connection URL (from the "Connect" tab from Mongo).

  3. Click on the "Variables" tab in your Parse Server and update:

Your server will re-deploy after these changes.

Manual Deployment

  1. Go to Railway, click "Start a New Project" and choose "Deploy from GitHub repo". Connect your GitHub account.

  2. Give permission for Railway to access your self-hosted server repository and click "Deploy Now":

  1. In your project's deployment page, click on the "Variables" tab and then "Raw Editor". Paste in your environment variables and click "Update Variables":

  1. Click on the "Settings" tab and under "Domains", click "Generate Domain". You can choose a different Railway domain or use your own custom domain:

  1. Copy this domain and update your SERVER_URL environment variable. Your project will re-deploy:

  1. After your re-deploy is successful, open your Railway project URL in your browser to test:

You are now self-hosting your own Moralis Server!

Google App Engine

Prerequisites

Deployment

Be aware!

If your Google Cloud free trial has ended, the following process could resort to expenses.

Replace the environment variables values in app.yaml with your own:

Open the terminal, make sure you're in the root folder and run:

gcloud app deploy

Choose your region:

Type Y to continue:

After a couple minutes the application is deployed:

Now run the following command to see it on the browser:

gcloud app browse

Add /server to the URL and you'll be accessing your Moralis Parse Server hosted on Google App Engine:

You are now self-hosting your own Moralis Server!

Last updated