Deployment
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
Create an AWS account.
Create an IAM user.
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.
After your server has deployed, assign it a domain (see Step 4 of Manual Deployment).
Copy your MongoDB and Parse connection URL (from the "Connect" tab from Mongo).
Click on the "Variables" tab in your Parse Server and update:
SERVER_URL
with the domain from Step 1 e.g.https://***.up.railway.app/server
DATABASE_URI
with your MongoDB connection URL e.g.mongodb://mongo:***.railway.app:****
REDIS_CONNECTION_STRING
with your Redis connection URL e.g.redis://***@containers-us-west-157.railway.app:****
Your server will re-deploy after these changes.
Manual Deployment
Go to Railway, click "Start a New Project" and choose "Deploy from GitHub repo". Connect your GitHub account.
Give permission for Railway to access your self-hosted server repository and click "Deploy Now":
In your project's deployment page, click on the "Variables" tab and then "Raw Editor". Paste in your environment variables and click "Update Variables":
Click on the "Settings" tab and under "Domains", click "Generate Domain". You can choose a different Railway domain or use your own custom domain:
Copy this domain and update your
SERVER_URL
environment variable. Your project will re-deploy:
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:
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:
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