Full Stack Development 14 min readOctober 5, 2026

How to Deploy MERN Stack Applications: A Complete Step-by-Step Guide for Pune Developers

By Trimaya TechnoSol

How to Deploy MERN Stack Applications: A Complete Step-by-Step Guide for Pune Developers

Building a MERN stack application is one thing. Deploying it to production — making it accessible to real users on the internet — is an entirely different skill set. And in 2026, Pune companies hiring full-stack developers expect candidates to know both.

Whether you are a fresher who has just completed a Java full-stack course in Pune and is exploring MERN, a self-taught developer preparing for interviews, or a working professional looking to upgrade your deployment skills — this guide covers everything you need to know about deploying MERN stack applications from development to production.

---

What Is the MERN Stack? A Quick Recap

MERN stands for:

  • M — MongoDB (NoSQL database)
  • E — Express.js (Node.js web framework)
  • R — React.js (frontend library)
  • N — Node.js (JavaScript runtime)

Together, these four technologies allow you to build a complete web application using JavaScript on both the frontend and backend. If you are comparing MERN with other stacks, read our detailed breakdown: MERN Stack vs MEAN Stack — Which Should You Learn?

---

Why Deployment Skills Matter for Pune Developers

Pune is one of India's top IT hubs. Companies in Hinjewadi, Kharadi, Viman Nagar, Baner, and Magarpatta hire full-stack developers at scale — and they expect candidates to go beyond just writing code.

In technical interviews at Pune IT companies, you will commonly be asked:

  • "Have you deployed any of your projects?"
  • "Which cloud platform have you used?"
  • "How do you handle environment variables in production?"
  • "What is your CI/CD pipeline?"

A developer who can answer these questions confidently stands out from the hundreds of candidates who only know how to build locally. If you are preparing for full-stack roles in Pune, read our guide on the Java full-stack developer roadmap 2026 alongside this article.

---

Prerequisites Before You Deploy

Before you start the deployment process, make sure your MERN application is ready:

1. Your Application Is Working Locally

Test every feature — authentication, API calls, database operations, file uploads — on your local machine before touching deployment.

2. Environment Variables Are Properly Configured

Never hardcode sensitive values like database connection strings, JWT secrets, or API keys in your source code. Use a .env file locally and environment variable settings on your deployment platform.

Example .env file:

MONGO_URI=mongodb+srv://username:[email protected]/dbname

JWT_SECRET=your_super_secret_key_here

PORT=5000

NODE_ENV=development

3. Your Code Is on GitHub

Every deployment workflow starts with a Git repository. Make sure your .env file is in .gitignore — never push secrets to a public repository.

4. Your Frontend and Backend Are Properly Separated

A MERN application has two parts:

  • Backend: Node.js + Express API (typically runs on port 5000)
  • Frontend: React app (typically runs on port 3000 in development)

In production, you have two main options:

  1. Deploy frontend and backend separately (recommended for larger apps)
  2. Serve the React build from the Express server (simpler for smaller apps)

---

Option A: Deploying Frontend and Backend Separately

This is the most common approach for production MERN applications. It gives you flexibility, independent scaling, and cleaner architecture.

Step 1: Deploy the Backend (Node.js + Express) to Render

Render is one of the most beginner-friendly platforms for deploying Node.js backends. It has a generous free tier and is widely used by developers in Pune and across India.

Steps:

  1. Go to render.com and create a free account
  2. Click New then Web Service
  3. Connect your GitHub repository
  4. Configure the service — Environment: Node, Build Command: npm install, Start Command: node server.js
  5. Add your environment variables: MONGO_URI, JWT_SECRET, NODE_ENV (production), PORT (10000)
  6. Click Create Web Service

Render will build and deploy your backend. You will get a URL like https://your-app-name.onrender.com.

Important: Update your Express CORS configuration to allow requests from your frontend domain:

const cors = require('cors');

app.use(cors({

origin: ['https://your-frontend-domain.vercel.app', 'http://localhost:3000'],

credentials: true

}));

---

Step 2: Set Up MongoDB Atlas (Cloud Database)

If you are still using a local MongoDB instance, you need to migrate to MongoDB Atlas for production.

  1. Go to mongodb.com/atlas and create a free account
  2. Create a new cluster — the free M0 tier is sufficient for most projects
  3. Under Database Access, create a database user with a strong password
  4. Under Network Access, add 0.0.0.0/0 to allow connections from anywhere
  5. Click Connect, then Connect your application, and copy the connection string
  6. Replace the password placeholder with your actual password
  7. Add this as the MONGO_URI environment variable on Render

---

Step 3: Deploy the Frontend (React) to Vercel

Vercel is the gold standard for deploying React applications. It is fast, free for personal projects, and integrates seamlessly with GitHub.

  1. Go to vercel.com and sign up with your GitHub account
  2. Click New Project and import your repository
  3. Configure: Framework Preset (Create React App or Vite), Root Directory (client if applicable), Build Command (npm run build), Output Directory (build or dist)
  4. Add environment variable: REACT_APP_API_URL set to your Render backend URL
  5. Click Deploy

Update your React API calls to use the environment variable instead of hardcoded localhost URLs.

---

Option B: Serving React Build from Express (Single Server Deployment)

This approach is simpler and works well for smaller applications or when you want to keep everything on one server.

Step 1: Build the React App

Run the following in your client directory:

npm run build

This creates a build folder (or dist for Vite) with optimised static files.

Step 2: Configure Express to Serve the React Build

In your main server.js or app.js, add the following after your API routes:

const path = require('path');

if (process.env.NODE_ENV === 'production') {

app.use(express.static(path.join(__dirname, 'client/build')));

app.get('*', (req, res) => {

res.sendFile(path.join(__dirname, 'client/build', 'index.html'));

});

}

Step 3: Update package.json Build Script

In your root package.json, add:

"scripts": {

"start": "node server.js",

"build": "cd client && npm install && npm run build"

}

Now deploy this entire project to Render as a single web service.

---

Option C: Deploying to AWS EC2 (VPS Deployment)

For developers targeting senior roles at Pune IT companies, knowing how to deploy on AWS is a significant advantage. This is also covered in our AWS DevOps career guide.

Step 1: Launch an EC2 Instance

  1. Log in to AWS Console and go to EC2 then Launch Instance
  2. Choose Ubuntu Server 22.04 LTS (free tier eligible)
  3. Select t2.micro instance type (free tier)
  4. Create or select a key pair — download the .pem file
  5. Configure Security Group — add inbound rules for SSH (port 22), HTTP (port 80), and HTTPS (port 443)
  6. Launch the instance

Step 2: Connect to Your EC2 Instance

chmod 400 your-key.pem

ssh -i your-key.pem ubuntu@your-ec2-public-ip

Step 3: Install Node.js, npm, and PM2

sudo apt update

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

sudo apt-get install -y nodejs

sudo npm install -g pm2

sudo apt install git -y

Step 4: Clone and Set Up Your Application

git clone https://github.com/yourusername/your-mern-app.git

cd your-mern-app

npm install

cd client && npm install && npm run build && cd ..

nano .env

Step 5: Start the Application with PM2

pm2 start server.js --name "mern-app"

pm2 startup

pm2 save

pm2 status

Step 6: Set Up Nginx as a Reverse Proxy

sudo apt install nginx -y

sudo nano /etc/nginx/sites-available/mern-app

Add this Nginx configuration:

server {

listen 80;

server_name your-domain.com www.your-domain.com;

location / {

proxy_pass http://localhost:5000;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection upgrade;

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

}

Enable and restart Nginx:

sudo ln -s /etc/nginx/sites-available/mern-app /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl restart nginx

Your MERN app is now accessible at your EC2 public IP on port 80.

---

Setting Up HTTPS with SSL Certificate

Never run a production application without HTTPS. On EC2, use Certbot (Let's Encrypt — free):

sudo apt install certbot python3-certbot-nginx -y

sudo certbot --nginx -d your-domain.com -d www.your-domain.com

sudo certbot renew --dry-run

On Vercel and Render, HTTPS is enabled automatically — no configuration needed.

---

Common Deployment Errors and How to Fix Them

Error: Cannot GET / on React Routes After Refresh

Cause: The server does not know about React Router routes and returns 404 on direct URL access.

Fix for Express: Add the catch-all route shown in Option B above.

Fix for Nginx: Add try_files inside your location block to fall back to index.html.

---

Error: CORS Policy Blocked

Cause: Your backend is not allowing requests from your frontend domain.

Fix: Update your CORS configuration to include the exact frontend URL with no trailing slash.

---

Error: MongoServerError — bad auth

Cause: Wrong MongoDB Atlas credentials or the database user does not have the right permissions.

Fix: Go to MongoDB Atlas, then Database Access, edit the user, and set the role to Atlas admin or Read and write to any database.

---

Error: Application Crashes After a Few Hours on EC2

Cause: The Node.js process is not managed by a process manager and crashes without restarting.

Fix: Use PM2 as shown in the EC2 deployment steps above. PM2 automatically restarts your application if it crashes.

---

Error: Environment Variables Undefined in Production

Cause: You are reading from a .env file that does not exist on the server.

Fix: Add environment variables directly in your platform's dashboard (Render, Vercel, or EC2 .env file). Never rely on a .env file being present on the production server.

---

Deployment Checklist Before Going Live

Before you share your deployed URL with anyone, run through this checklist:

  • All environment variables are set on the production platform
  • .env file is in .gitignore and not pushed to GitHub
  • MongoDB Atlas network access is configured correctly
  • CORS is configured with the exact production frontend URL
  • HTTPS is enabled (SSL certificate is active)
  • All API endpoints are tested in production (not just locally)
  • Error handling is in place — no raw error messages exposed to users
  • React build is optimised using npm run build, not npm start
  • PM2 or equivalent process manager is running for VPS deployments
  • Custom domain is pointing to the correct server

---

How Deployment Skills Help You Get Hired in Pune

Pune's IT companies — from startups in Baner to MNCs in Hinjewadi — increasingly expect full-stack developers to own the entire development lifecycle, not just the coding part.

When you can say in an interview: "I built this project and deployed it on AWS EC2 with Nginx, PM2, and Let's Encrypt SSL" — you immediately stand out from candidates who only have local projects.

If you are just starting your full-stack journey, read our guide on how to start a career in IT without a degree — it covers the complete roadmap for breaking into Pune's IT industry regardless of your educational background.

For structured training in full-stack development with hands-on deployment practice, visit Trimaya TechnoSol on FC Road, Pune. Our Java full-stack course in Pune includes real deployment projects as part of the curriculum — so you graduate with live, deployed applications in your portfolio, not just local projects on your laptop.

To understand which institute is right for you, read our detailed comparison: Best IT Institute in Pune.

---

FAQ: Deploying MERN Stack Applications

Q1. Which is the best platform to deploy a MERN stack app for free?

For beginners, Render (backend) + Vercel (frontend) + MongoDB Atlas (database) is the best free combination. All three have generous free tiers and are widely used by developers in Pune and across India. For production-grade deployments, AWS EC2 or DigitalOcean are preferred.

---

Q2. Can I deploy the entire MERN stack on a single server?

Yes. You can serve the React build from your Express server and deploy everything as a single Node.js application on Render, Railway, or an EC2 instance. This is simpler but less scalable than separating frontend and backend.

---

Q3. How much does it cost to deploy a MERN stack app on AWS?

An AWS EC2 t2.micro instance is free for the first 12 months under the AWS Free Tier. After that, it costs approximately Rs. 600 to Rs. 900 per month. For a production app with moderate traffic, a t3.small instance costs around Rs. 1,500 to Rs. 2,000 per month.

---

Q4. Do I need to know DevOps to deploy a MERN stack app?

Not for basic deployments. Platforms like Render and Vercel handle most of the infrastructure for you. However, for AWS EC2 deployments — which are expected in senior roles at Pune IT companies — basic Linux, Nginx, and PM2 knowledge is required. Our AWS DevOps career guide covers these skills in detail.

---

Q5. What is PM2 and why do I need it?

PM2 is a process manager for Node.js applications. Without it, if your Node.js server crashes due to an unhandled error, memory issue, or server restart, your application goes offline and stays offline until you manually restart it. PM2 automatically restarts the application, keeps it running across server reboots, and provides logging and monitoring.

---

Q6. How do I update my deployed MERN app after making code changes?

On Render and Vercel, push to your GitHub repository — both platforms auto-deploy on every push to the main branch if auto-deploy is enabled. On EC2, SSH into the server, run git pull, rebuild the frontend if needed, and restart PM2 with: pm2 restart mern-app.

---

Q7. Is MERN stack in demand in Pune in 2026?

Yes. MERN stack developers are actively hired by Pune startups, product companies, and service firms. The demand is particularly strong for developers who can build and deploy full-stack applications independently. If you are comparing MERN with other stacks, read MERN Stack vs MEAN Stack to understand which is more relevant for Pune's job market.

---

Q8. Where can I learn MERN stack deployment in Pune?

At Trimaya TechnoSol on FC Road, Pune, our full-stack development program covers MERN stack development and deployment as part of the curriculum. Students build and deploy real projects during training — giving them live portfolio projects that Pune companies can actually visit and evaluate. Visit our best IT institute in Pune page to learn more about our programs.

---

Q9. What is the difference between development and production environments in MERN?

In development, you run the React dev server and Node.js server separately, with hot reloading and detailed error messages. In production, you build the React app into optimised static files, run Node.js with NODE_ENV set to production which disables detailed error messages for security, and use a process manager like PM2. Environment variables, CORS settings, and database connections are also typically different between the two environments.

---

Q10. How long does it take to deploy a MERN app for the first time?

For a beginner using Render + Vercel + MongoDB Atlas, the first deployment typically takes 2 to 4 hours including setup, configuration, and debugging. For an AWS EC2 deployment, expect 4 to 8 hours for the first time. With practice, the same process takes 30 to 60 minutes.

---

Trimaya TechnoSol is a leading IT training institute on FC Road, Pune, offering full-stack development (MERN, Java), software testing, data science, and digital marketing programs for freshers and career switchers across Pune — including students from Kothrud, Karve Nagar, Warje, Bavdhan, Pashan, and Aundh.

Share this article

Start Your IT Career

Get free career counselling from our experts.

🔒 Your data is safe. No spam, ever.