How to Deploy MERN Stack App on VPS
How to Deploy MERN Stack App on VPS
Deploying a MERN app (MongoDB, Express, React, Node.js) on a VPS gives you full control and low cost. This guide walks from server setup to production.
Beginner: VPS and Access
1. Provision a VPS – Any provider (DigitalOcean, Linode, Vultr, etc.). Ubuntu 22.04 LTS is a solid choice.
2. SSH access – ssh root@your-server-ip. Create a non-root user and use SSH keys; disable password login for root.
3. Basics – apt update && apt upgrade -y; set hostname and firewall (ufw: allow 22, 80, 443).
Intermediate: Node, MongoDB, and App
1cd /var/www/myapp2git pull3npm ci --production4npm run buildAdvanced: PM2 and Nginx
Expert: CI/CD and Hardening
Validate configs and API payloads before deploy with our [JSON Formatter](/tools/json-formatter/) and [YAML Formatter](/tools/yaml-formatter/).
Related tools
Try these free developer tools from Codev Nexus.
Enjoyed this article?
Support our work and help us create more free content for developers.
Stay Updated
Get the latest articles and updates delivered to your inbox.