Deploy MERN apps for free. Ethnus Codemithra article cover.

Deploy a MERN app for free: Atlas, Render and env vars

Codemithra Team

Codemithra Team

You can deploy a MERN app for free using three separate free-tier services. Host the database on a MongoDB Atlas free cluster, which never expires and needs no credit card. Host the Express API on a Render web service. Host the React build on a Render static site. Then wire the three together with environment variables. Check the two spots where a first deployment usually breaks: connection strings and CORS.

Checked against the official MongoDB Atlas and Render documentation on 8 September 2026.

Why deployment trips up MERN projects

A local MERN app runs as three processes on one machine. These are a MongoDB server, an Express API, and a React development server, each on its own localhost port. Deploying it means finding a free home for each piece, then telling each one where to find the other two.

Most first deployments fail at exactly two points. The API cannot reach the database, because a connection string or an IP restriction is wrong. The browser can also fail to reach the API, because of a CORS rule or a leftover localhost URL. This guide fixes both, using MongoDB Atlas for the database and Render for the API and the frontend.

The three pieces and where each one lives

Once deployed, a request travels through three separate hosts before it reaches the database. The diagram below shows that full path. It also marks the point where a request can stall while a spun-down API wakes up.

How the three free services connect. Browser to static site: Requests the React build from the Render static site, served over its CDN and always on Then Static site to web service: The React app calls the Express API at its Render web service URL, which may cold start after 15 minutes idle and take about a minute to wake Then Web service to environment variables: Express reads the Mongo connection string from Render environment variables, never hard-coded in the repository Then Web service to MongoDB Atlas: Express connects to the free Atlas cluster over mongodb+srv, allowed only because the connecting IP is on the cluster IP access list
Sources: MongoDB Atlas and Render documentation, checked 8 September 2026.
  • MongoDB Atlas hosts the database on a free M0 cluster.
  • A Render web service hosts the Express API.
  • A Render static site hosts the built React app.

Step 1: create a free MongoDB Atlas cluster

Sign in to MongoDB Atlas and create a project. Then deploy a free M0 cluster by choosing a cloud provider and a region. The cluster becomes ready in under 15 seconds. It never expires and needs no credit card. Atlas allows only one free cluster per project (MongoDB Atlas).

Next, create a database user under Database Access. Atlas authenticates that user with SCRAM-SHA-256 by default. Pick a role scoped to just the database your app uses, rather than a broad one (MongoDB Atlas). Add your current IP address, or a range you control, to the project IP access list under Network Access. Atlas only allows client connections from an address already on that list (MongoDB Atlas).

Finally, select Connect on the cluster and copy the mongodb+srv:// connection string. This SRV format resolves the cluster hosts through DNS. MongoDB recommends it over the older standard mongodb:// format whenever it is available (MongoDB manual). Replace the placeholder password with the real password for that database user, before using the string anywhere.

Remember one gotcha before your demo. Atlas automatically pauses a free cluster after 30 days with zero connections (MongoDB Atlas). Pausing is not deletion. A paused cluster needs a manual resume from the Atlas dashboard before it accepts connections again.

Step 2: keep secrets out of your code

Before deploying anything, remove real credentials from your repository. Create a .env file in the Express project root. Add it to .gitignore, then store the Atlas connection string there as MONGO_URI. Read it in code with process.env.MONGO_URI. The real value then lives only in that local file, and later in the Render environment variable settings.

The frontend follows a different rule. In a Vite-built React app, only variables prefixed VITE_ are exposed to the browser. Vite bundles them into the built JavaScript at build time (Vite). That means a VITE_ variable is never actually secret. Anyone can open the built files for your site and read it.

The Vite documentation warns against putting sensitive information, such as API keys, in a VITE_ variable. The same caution applies to a Create React App variable prefixed REACT_APP_. Use these prefixes only for values that are safe to expose, such as the base URL of your deployed API.

Step 3: deploy the Express API as a Render web service

On Render, create a web service and connect the GitHub repository holding your Express API. Set a build command such as npm install and a start command such as npm start. Render then rebuilds and redeploys automatically on every push to the linked branch (Render).

Open the Environment tab for that service and add each variable your API needs, including MONGO_URI. Use the "+ Add Environment Variable" control to do this. Saving offers a choice: rebuild and deploy, redeploy the existing build, or save the values without deploying yet (Render).

Two free-tier limits shape how this API behaves in front of reviewers. A workspace gets 750 free instance-hours a month across its free web services. Going over that limit suspends all of them until the next month (Render).

A free web service also spins down after 15 minutes with no inbound traffic. Waking it back up takes about a minute (Render). The first request after idle time looks slow, not broken. Free web services also have no persistent disk. Do not rely on saving uploaded files to storage on the server itself.

Step 4: deploy the React frontend as a Render static site

Create a second Render service, this time a static site, pointed at the frontend folder of the same repository. A Create React App project builds with a command that runs yarn and then yarn build. It publishes from the build directory (Render). A Vite project instead publishes from dist.

React Router needs one extra setting. Add a rewrite rule that sends any path (/*) to /index.html. This stops a refreshed client-side route from returning a server 404 (Render). Render serves static sites over a global CDN, with managed TLS included at no cost (Render). Render does not document any spin-down behaviour for static sites. Your frontend therefore loads instantly, even while the API behind it is still waking up.

Step 5: connect the frontend to the backend and fix CORS

With both services deployed, point the frontend at the real API. Add an environment variable such as VITE_API_URL, set to the URL of your Render web service. Use it wherever the frontend currently calls localhost.

On the API side, allow only the Render origin of that frontend in your CORS configuration. Do not leave it open to every origin. The snippet below is illustrative. It shows the shape of the fix, not the actual values from one specific deployment.

require('dotenv').config();
const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');

mongoose.connect(process.env.MONGO_URI);

const app = express();
app.use(cors({
  origin: 'https://your-frontend.onrender.com',
}));

What each free tier limits, and what it means for your demo

Component Where it runs Free-tier limit What it means for your demo
Database MongoDB Atlas free cluster 0.5 GB storage, 500 connections, auto-pauses after 30 days with zero connections (MongoDB Atlas) Do not panic if a dormant project needs a manual resume before it reconnects
API Render web service 750 free instance-hours a month per workspace, spins down after 15 minutes idle, about a minute to wake (Render) Warn a reviewer the first request may take about a minute
Frontend Render static site Free, CDN-served, managed TLS included, no documented spin-down (Render) Loads instantly, but it is a static shell waiting on the API to wake

How this connects to the Ethnus MERN Full Stack program

Deploying a React app to the web is an explicit syllabus topic in the Ethnus MERN Full Stack program. It is not something students have to work out alone after the course ends. The same syllabus includes a dedicated MongoDB module covering CRUD operations, aggregations, indexing, replication and sharding. It also includes an Express.js module covering middleware and request handling. A React section covers HTTP requests and AJAX calls, the skill the frontend-to-API step in this guide depends on.

Trainers give step-by-step walkthroughs and clear doubts as they come up. The Codemithra Learning & Assessment Platform (CLAP) gives module-based assignments, so you can practise each piece before connecting them together.

Quick recap and troubleshooting checklist

If your deployed app does not work, check these in order.

  • Confirm MONGO_URI is set in the Render Environment tab, not only in your local .env file. Render never reads files from your machine.
  • Confirm your connecting IP is on the IP access list for that Atlas project.
  • Confirm the frontend CORS origin matches the exact URL of the Render static site, including https.
  • Give a spun-down API about a minute to wake up before assuming the deploy failed.
  • Confirm any frontend environment variable starts with VITE_ (or REACT_APP_ for Create React App). Rebuild the static site after adding it.

Frequently asked questions

Does the MongoDB Atlas free cluster expire?

No. Atlas free clusters never expire and need no credit card. Atlas allows only one free cluster per project (MongoDB Atlas).

Why does my Render API feel slow the first time I open it?

A free Render web service spins down after 15 minutes with no inbound traffic. Waking it back up takes about a minute (Render). That first slow request after idle time is expected, not a broken deploy.

Can I store uploaded files on my Render API?

Not reliably. Free Render web services have no persistent disk. Files saved to storage on the server itself do not survive a restart or a new deploy (Render). Keep uploads in Atlas or another external store instead.

Why can the browser see my frontend environment variable?

Vite bundles any VITE_ prefixed variable into the built JavaScript at build time. It is never actually secret once deployed (Vite). Keep real secrets only in the Express API environment variables, never in the frontend.

What happens if I forget about a deployed capstone project?

Atlas pauses a free cluster automatically after 30 days with zero connections (MongoDB Atlas). Resume it manually from the Atlas dashboard before your next demo.

See the full curriculum, including the MongoDB, Express and deployment modules, on the Ethnus Codemithra MERN Full Stack program page.

About the Author

Read More

Ethnus User Agreement

I agree to submit my personally identifiable information to Ethnus, who may use it to communicate regarding their events, courses, and other services through various media including phone calls, text messages, email, and social media. I also agree with Ethnus' Privacy Policy and Terms of Service.

I agree with Ethnus sharing my personal data, including email address, with Salesforce family of companies, who may contact me for sales and marketing purposes and as described in Salesforce's Privacy Statement.

Privacy Policy

This Privacy Notice describes how we collect and use your personal information in relation to Ethnus websites, applications, products, services, events, and experiences that reference this Privacy Notice (together, "Ethnus Offerings").

This Privacy Notice does not apply to the "content" processed, stored, or hosted by our customers using Ethnus Offerings in connection with an Ethnus account. This Privacy Notice also does not apply to any products, services, websites, or content that are offered by third parties or have their own privacy notice.

Personal Information We Collect

We collect your personal information in the course of providing Ethnus Offerings to you.

Here are the types of information we gather:

        a) Information You Give Us: We collect any information you provide in relation to Ethnus Offerings. Click here to see examples of information you give us. Example: Name, email, phone, etc.

        b) Automatic Information: We automatically collect certain types of information when you interact with Ethnus Offerings. Example: IP address, location, browser identity, etc.

        c) Information from Other Sources: We might collect information about you from other sources, including service providers, partners, and publicly available sources. Example: marketing analytics, keywords, etc.

How We Use Personal Information

We use your personal information to operate, provide, and improve Ethnus Offerings. Our purposes for using personal information include:

        a) Provide Ethnus Offerings: We may use your personal information to provide and deliver Ethnus Offerings and process transactions related to Ethnus Offerings, including registrations, subscriptions, purchases, and payments.

        b) Measure, Support, and Improve Ethnus Offerings: We use your personal information to measure use of, analyze the performance of, fix errors in, provide support for, improve, and develop Ethnus Offerings.

        c) Recommendations and Personalization: We use your personal information to recommend Ethnus Offerings that might be of interest to you, identify your preferences, and personalize your experience with Ethnus Offerings.

        d) Comply with Legal Obligations: In certain cases, we have a legal obligation to collect, use, or retain your personal information.

        e) Communicate with You: We use your personal information to communicate with you in relation to Ethnus Offerings via different channels (e.g., by phone, email, chat) and to respond to your requests.

        f) Marketing: We use your personal information to market and promote Ethnus Offerings. We might display interest-based ads for Ethnus Offerings.

        g) Purposes for Which We Seek Your Consent: We may also ask for your consent to use your personal information for a specific purpose that we communicate to you.

Cookies

To enable our systems to recognize your browser or device and to provide Ethnus Offerings, we use cookies.

How We Share Personal Information

Information about our customers is an important part of our business and we are not in the business of selling our customers' personal information to others. We share personal information only as described below and with Ethnus Consultancy Services Private Limited, . and its affiliates that are either subject to this Privacy Notice or follow practices at least as protective as those described in this Privacy Notice.

Transactions Involving Third Parties: We make available to you services, software, training, and content provided by third parties for use on or through Ethnus Offerings. You can tell when a third party is involved in your transactions, and we share information related to those transactions with that third party. For example, you can order services, software, and content from sellers using the Authorized Training Partner's marketplace and we provide those sellers information to facilitate your subscription, purchases, or support.

Other than as set out above, you will receive notice when personal information about you might be shared with third parties, and you will have an opportunity to choose not to share the information.

How We Secure Information

        a) We protect the security of your information during transmission to or from websites, applications, products, or services by using encryption protocols and software.

        b) We maintain physical, electronic, and procedural safeguards in connection with the collection, storage, and disclosure of personal information.

Internet Advertising and Third Parties

Ethnus Offerings may include third-party advertising and links to other websites and applications. Third party advertising partners may collect information about you when you interact with their content, advertising, or services. For more information about third-party advertising, including interest-based ads, please read our Interest-Based Ads notice.

Access and Choice

You have choices about the collection and use of your personal information. Many Ethnus Offerings include settings that provide you with options as to how your information is being used. You can choose not to provide certain information, but then you might not be able to take advantage of certain Ethnus Offerings.

        a) Communications: If you do not want to receive promotional messages from us, please unsubscribe or adjust your communication preferences in the emails.

        b) Advertising: If you don't want to see interest-based ads, please adjust your Advertising Preferences.

        c) Browser and Devices: The Help feature on most browsers and devices will tell you how to prevent your browser or device from accepting new cookies, how to have the browser notify you when you receive a new cookie, or how to disable cookies altogether.

Children's Personal Information

We don't provide Ethnus Offerings for purchase by children. If you're under 18, you may use Ethnus Offerings only with the involvement of a parent or guardian.

Retention of Personal Information

We keep your personal information to enable your continued use of Ethnus Offerings, for as long as it is required in order to fulfill the relevant purposes described in this Privacy Notice, as may be required by law (including for tax and accounting purposes), or as otherwise communicated to you. How long we retain specific personal information varies depending on the purpose for its use, and we may delete your personal information in accordance with applicable law.

Contacts, Notices, and Revisions

If you have any concern about privacy at Ethnus, you may also contact us at the addresses below:

Ethnus Consultancy Services Pvt Ltd,

SST Chambers, No.151/17/1 Second Floor, 36th Cross Rd, 5th Block, Jayanagar, Bengaluru, Karnataka 560041

Or, email us at [email protected]

Or call us at: +91 - 8929 334 324

You will find the updated contact information on our website: www.ethnus.com/contact/

If you interact with Ethnus Offerings on behalf of or through your organization, then your personal information may also be subject to your organization's privacy practices, and you should direct privacy inquiries to your organization.

Our business changes constantly, and our Privacy Notice may also change. You should check our website frequently to see recent changes. You can see the date on which the latest version of this Privacy Notice was posted. Unless stated otherwise, our current Privacy Notice applies to all personal information we have about you and your account. We stand behind the promises we make, however, and will never materially change our policies and practices to make them less protective of personal information collected in the past without informing affected customers and giving them a choice.

Terms & Conditions

This Privacy and Security Policy is provided for the benefit of customers and clients of Ethnus Consultancy Services Private Limited. ("Ethnus") as well as other consumers and parties who use Ethnus and/or its website(s), particularly codemithra.com ("Website", "www.codemithra.com", "Codemithra" or "Ethnus Codemithra"), and/or applications ("Apps") (collectively, "Ethnus Services" or "Ethnus Platform").

Since Ethnus serves several different audiences, customers find it helpful to read the Terms of Use that apply specifically to them based upon the purpose for which they use Ethnus. For this reason, we link to three separate agreements below for employer customers, job seeker customers, and staffing customers, respectively.

For your convenience, we define each of these audiences that Ethnus serves as follows:

"Employer Customer" means an entity using Ethnus Services that is seeking to hire an individual as an employee and/or independent contractor to be employed by it directly.

"Job Seeker Customer" means an individual using Ethnus Services who is seeking to be employed as an employee or independent contractor by an employer.

"Staffing Customer" means a staffing company using Ethnus Services that provides staffing services to their own Staffing Clients.

So long as your use of the Ethnus website and services remains within the scope of the particular audience or customer for which you began using Ethnus (e.g. a job seeker does not use Ethnus as an employer, or an employer does not use Ethnus as a job seeker), the complete Terms of Use applicable to your use of the Ethnus website and services is contained within the applicable Terms of Use linked below.

Employer Terms of Use

The following Terms of Use apply to any Ethnus Employer Customer seeking to hire employees or independent contractors for its own business. If you seek to find employees or independent contractors for the benefit of your clients (and not yourself), you need to review the Terms of Use specifically for our Ethnus Staffing Customers accessible at www.Codemithra.com/terms/staffing.

Ethnus, Inc. ("Ethnus") provides online services through which employers and staffing companies seeking employees and independent contractors can efficiently and effectively review and interview candidates. Ethnus provides these services and its suite of features and products through its Apps and Website (collectively, "Ethnus Services") subject to these terms of use ("Terms of Use") and the agreements incorporated herein.

Your privacy is very important to us. We designed our accompanying Privacy and Security Policy to provide important disclosures about how your information will be used by Ethnus in providing you Ethnus Services. These Terms of Use expressly incorporate our Privacy and Security Policy.

Please read these Terms of Use and our Privacy and Security Policy carefully before using any of the diverse Ethnus Services. By visiting the Website, installing any of the Apps, and/or using any of the Ethnus Services, you shall have affirmed your agreement to these Terms of Use.

1. Definitions

2. Modifications - Will Ethnus ever modify these Terms of Use?

3. Ethnus Services - What are the Ethnus Services?

4. Video Content and Services - How and when do you record videos?

5. Pricing, Payments, and Billing - How and when will I be billed for Ethnus Services?

6. Objectionable Content - What if I find content to be objectionable?

7. Customer Conduct

8. Intellectual Property

9. DMCA Policy

10. Reserved for Future Use

11. Resale of Services

12. Indemnification

13. Disclaimer of Warranties

14. Third Party Links and Products

15. Limitations of Liability

16. Exclusions and Limitations

17. General Terms

1. Definitions

"Consumer" means any individual or entity that uses any of the Ethnus Services. Where applicable, the term "Consumer" shall encompass all Ethnus Customers.

"Content" means all material, whether publicly posted or privately transmitted, available on or through any of the Ethnus Services.

"Customer" means, for purposes of this Terms of Use, You, a Job Seeker Customer.

"Customer Content" means any Content uploaded to and/or created through the Ethnus Services by a Ethnus Customer.

"Employer Customer" means an entity using Ethnus Services that is seeking to hire an individual as an employee and/or independent contractor to be employed by it directly.

"GDPR" means the European Union's General Data Protection Regulation.

"Job Seeker Customer" means an individual using Ethnus Services who is seeking to be employed as an employee or independent contractor by an employer.

"Profile Video" means a promotional video created by a Job Seeker Customer to promote themselves as a candidate employee and/or independent contractor. It is not an interview. The Job Seeker Customer completes this independently and on their own.

"Software" means any necessary software used in connection with the Ethnus Services.

"Ethnus Account" means an account associated with a Ethnus Customer who uses or has used Ethnus Services.

"Ethnus Content" means any Content excluding Customer Content and Video Content in which Ethnus does not participate.

"Ethnus Customer" means any person who uses or has used Ethnus Services including, but not limited to, Employer Customers, Job Seeker Customers, and Staffing Customers.

"Ethnus Services" means the suite of features, products and services offered through Ethnus, its Apps, its App Services, the Website, and the Website Services.

"Ethnus Trademarks" means any trademarks, tradenames, logos, and other commercial designs of Ethnus or licensed to Ethnus, whether or not formal registration exists including, but not limited to, "Ethnus."

"Staffing Clients" means third-party employer clients of Staffing Customers.

"Staffing Customer" means a staffing company using Ethnus Services that provides staffing services to their own Staffing Clients.

"Strategic Partners" means those trusted partners that Ethnus employs, engages, or retains to perform functions and/or provide services on its behalf.

"Sub Accounts" means subsidiary accounts created for or by an Employer Customer or Staffing Customer ("such as a consultant group or employer") under its primary account.

"Username" means the valid email address provided by each Ethnus Customer to be used as their username or login identification.

"Video Content" means any video content created by or associated with any Ethnus Customer accessible on and through Ethnus Services including, but not limited to, Profile Videos, Video Questions, Video Interviews, and Welcome Videos.

"Video Interview" means an interview completed through Ethnus Services using a video or "web" camera that an Employer Customer or Staffing Customer requests a Job Seeker Customer complete. A Video Interview may involve a Job Seeker Customer alone or with other participants from an Employer Customer or Staffing Customer. A Video Interview may be pre-recorded by a Job Seeker in response to questions or occur live at which time it would be recorded.

"Video Question" means a question recorded in video and audio that can be sent to potential employee and independent contractor candidates by an Employer Customer or Staffing Customer.

"Website" means all of the content, information and services (in any format whatsoever) accessible through the World Wide Web at the domain name Codemithra.com.

"Website Services" means the services provided by Ethnus through the website at the domain name Codemithra.com, hire.li, and any of our other websites that may be used from time to time