---
title: "Deploy Railway Ram Restart"
description: "Monitors ram usage and restarts when exceeded. Supports automatic restarts"
category: "Automation"
url: https://railway.com/deploy/1FHSG9
---

# Deploy Railway Ram Restart

Monitors ram usage and restarts when exceeded. Supports automatic restarts

**[Deploy Railway Ram Restart on Railway](https://railway.com/template/1FHSG9)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/1FHSG9/manifest.json

- **Creator:** dClimate
- **Category:** Automation
- **Total deploys:** 19

## Template content

### railway-ram-restart

- **Source:** dClimate/railway-ram-restart
- **Start command:** `node index.js`

## Documentation

This template will help you control and restart any services that continue to increase in ram usage due to a memory leak or some other reason.

You have 2 options:

Option 1 allows you to monitor the ram usage of a service and restart it if it exceeds your ram usage limit. This works by setting `MAX_RAM_CRON_INTERVAL_CHECK` using your preferred cron configuration such as `* * * * *`. You must also set `MAX_RAM_GB`. For 1GB you just set `1`, for anything less than 1GB it is `0.5` for example

Option 2 allows you to restart the service at a defined cron interval regardless of the ram usage. You use the env `CRON_INTERVAL_RESTART`. You can define it for in the middle of the night to prevent impacting others such as `0 4 * * *`

You must also set `RAILWAY_API_TOKEN` and `TARGET_SERVICE_NAME`. The target service name is the service you would like the ram monitor to monitor.

The template further uses `RAILWAY_PROJECT_ID`, `RAILWAY_ENVIRONMENT_ID`, and `RAILWAY_ENVIRONMENT_NAME`. These are however automatically set by railway. This means the monitor will only target the service name in the same environment it is  hosted. You could target other environments by changing these variables manually.

## Similar templates

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — Automate WhatsApp workflows with Evolution API, n8n, and Postgres.
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

Open this page in a browser: https://railway.com/deploy/1FHSG9
