How to Deploy Directus to Render.com
Tags: deployment, directus, render, postgres
Published: 2024-04-06 18:35:20

---
title: How to Deploy Directus to Render.com
published: true
date: 2024-04-03 01:54:33 UTC
tags: Deployment, Directus, Render, PostgreSQL
canonical_url: https://blog.jamin.sh/how-to-deploy-directus-to-rendercom
---

[Directus](https://directus.io/) is an open-source backend-as-a-service platform that offers a user-friendly interface that simplifies building fully functional backend services, APIs, and graphQL endpoints. This ease of use extends to [Render](https://render.com/), a fully managed cloud platform where you can effortlessly host static sites, backend APIs, databases, and all other components for your web application. In this article, you'll learn how to deploy a self-hosted instance of Directus to Render and connect it to a PostgreSQL database.

## Prerequisites

Before you begin this tutorial, you will need a [Render](https://render.com/) account; the free plan is good enough to follow along with this tutorial.

## Step 1: Set Up a PostgreSQL Database

On your [Render](http://Render.com) account[,](http://render.com/), click on the New + button and Click on PostgreSQL to create a new PostgreSQL database.

![Screenshot of Create a new PostgreSQL database in Directus](https://cdn.hashnode.com/res/hashnode/image/upload/v1712107775927/02e0fb4b-cbb1-4817-a9d6-1e1637a4a4da.png)

On the database creation page, add a name for your PostgreSQL instance, a database name, a user, and the region from which you want the PostgreSQL instance to run. Also, select For hobby projects as the instance type for a free tier.

![New PostgreSQL page](https://cdn.hashnode.com/res/hashnode/image/upload/v1712107844697/6164ddc7-284d-41a0-9f29-3ec79a65a4a6.png)

Next, click on the Create Database button to create your PostgreSQL database.

You should be redirected to the created database page.

![Database page](https://cdn.hashnode.com/res/hashnode/image/upload/v1712107909079/20902436-077c-4277-abb5-6bfcce65645d.png)

You can scroll down to the **Connections** tab to find the credentials needed to communicate with the database you created.

![Connections section in Database page](https://cdn.hashnode.com/res/hashnode/image/upload/v1712107994973/6d1ea596-0eb2-40d6-b063-6a1a51e87a7a.png)

Copy the `hostname`, `port`, `database`, `username`, and `password` and save them, as youll need them when creating an instance of Directus later in the next step of this tutorial:

## Step 2: Deploy an Instance of Directus from Docker Hub

On your [Render.com](http://Render.com) account[,](http://render.com/) click on the New + button and Click on Web Service to create a new web service

![Create new web service screenshot](https://cdn.hashnode.com/res/hashnode/image/upload/v1712108252611/38d2e2ad-651d-4852-a568-f733cbd9af99.png)

Select the second option on the How would you like to deploy your web service? page, then click next.

![New Web service page options](https://cdn.hashnode.com/res/hashnode/image/upload/v1712108313905/df6366c0-3749-461e-bbb0-a9da1e901ca4.png)

The next page will ask you for the image URL you want to deploy. Paste the official Directus URL from the Docker hub below into the input field, and click on next:

```
https://hub.docker.com/r/directus/directus
```

On the web service creation page, you can add your preferred name for your web service and the region where you want the web service to run; also, select the **For Hobby Projects** as the **Instance Type** plan.

![Web service creation page](https://cdn.hashnode.com/res/hashnode/image/upload/v1712108548578/3b95136e-701c-432d-9045-aa33334a3945.png)

On the **Environment Variables** tab, add the following variables to set up the Directus instance:

```
ADMIN_EMAIL = admin@example.comADMIN_PASSWORD = d1r3ctu5DB_CLIENT = postgresDB_DATABASE = YOUR_DB_NAME_FROM_STEP_1DB_HOST = YOUR_DB_HOSTNAME_FROM_STEP_1DB_PASSWORD = YOUR_DB_PASSWORD_FROM_STEP_1DB_PORT = 5432DB_USER = YOUR_DB_USER_FROM_STEP_1KEY = YOUR_RANDOM_KEYSECRET = YOUR_RANDOM_SECRETWEBSOCKETS_ENABLED = true
```

Click on the Create Web Service button, and a new instance of Directus will be deployed as a web service.

After deployment, you will be redirected to the web service page with all the details about your web service. Click on the live URL of your web service, and it should open Directus in a new tab.

![Directus deployed as a new web service in Render](https://cdn.hashnode.com/res/hashnode/image/upload/v1712108788150/ac0bc16e-0062-416e-bce6-2d0e67c9d243.png)

Congratulations! 🥳 you've just deployed an instance of Directus on [Render](http://Render.com) and connected it to a PostgreSQL database.

## Summary

In this article, you successfully created a PostgreSQL instance and deployed Directus to [Render.com](http://Render.com); some possible next steps you can take to improve your deployment might include setting up autoscaling to handle large incoming requests on your Directus application and enabling cron jobs to run backups for your application. (This involves upgrading to a paid account on [Render](http://Render.com) 😉).

Directus also has a [Directus Cloud](https://directus.io/cloud) version that offers constant backups, rolling updates, round-the-clock monitoring, and the ability to restart automatically during a crash.

I hope this article is helpful to you.

Happy coding!🍻

I'd love to connect with you on [**Twitter**](https://twitter.com/codejagaban) | [**LinkedIn**](https://www.linkedin.com/in/codejagaban/) | [**GitHub**](https://github.com/codejagaban/)