🚀 Deployed an Express App to the Cloud (with Render)


Source code - https://github.com/palashshrote/quizzy
Live on - https://quizzy-lase.onrender.com/
Deploying an Express.js app on the cloud isn’t as daunting as it sounds — especially with Render, which offers clear and concise documentation (https://render.com/docs/deploy-node-express-app) to guide.
✅ My Deployment Process
I started by uploading my project to GitHub and followed the steps outlined in Render’s docs. Simple and effective!
⚠️ Error I Encountered
Initially, I hardcoded the port number in my Express app (const port = 3000
), which caused the deployment to fail.
💡 How I Fixed It
To make my app cloud-compatible, I:
Created a
.env
file with:
PORT=3000
Installed the
dotenv
package.In my app:
Imported dotenv:
import dotenv from "dotenv";
Configured it:
dotenv.config();
Applied:
const port = process.env.PORT || 3000;
Overrode the environment variable in the Render dashboard (you can set it under the "Environment" tab).
⚙️ Optimizations
I also ensured a clean GitHub push by using a .gitignore
file to exclude:
node_modules/
.env
package-lock.json
🤯 Fun Fact
Even if you don’t use the dotenv
package or don’t manually set the port, it still works on Render.
That’s because:
Render automatically provides a
PORT
via environment variables.The default port is typically
10000
(but the app still needs to bind toprocess.env.PORT
).
Subscribe to my newsletter
Read articles from Palash Shrote directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
