Express.js is the most widely used web framework for Node.js. It powers REST APIs, web applications, and microservices across startups and enterprises alike. Deploying an Express application to production typically involves configuring servers, reverse proxies, process managers, and SSL certificates.
With Out Plane, you can deploy your Express.js application in under a minute. This guide shows you exactly how.
What You'll Need
Before starting, make sure you have:
- Node.js 20+ installed on your machine
- A GitHub account
- An Express.js application in a GitHub repository
- A
package.jsonwith your dependencies
Don't have Node.js installed? Download it from nodejs.org:
- Windows: Download the LTS installer from nodejs.org
- macOS: Use
brew install nodeor download from nodejs.org - Linux: Run
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs(Ubuntu/Debian)
Once Node.js is installed, create a project folder and initialize it:
mkdir my-express-app && cd my-express-app
npm init -y
npm install expressIf you don't have an Express app yet, use our example below.
Quick Start: Sample Express.js Application
Here's a minimal Express.js application you can use. Create these files in your repository:
Create app.js:
const express = require("express");
const app = express();
const port = process.env.PORT || 8080;
app.use(express.json());
// Home route
app.get("/", (req, res) => {
res.json({
message: "Hello from Express.js!",
status: "running",
});
});
// Health check
app.get("/health", (req, res) => {
res.json({ status: "healthy" });
});
// Sample API endpoint
const items = [
{ id: 1, name: "Item One" },
{ id: 2, name: "Item Two" },
{ id: 3, name: "Item Three" },
];
app.get("/api/items", (req, res) => {
res.json(items);
});
app.get("/api/items/:id", (req, res) => {
const item = items.find((i) => i.id === parseInt(req.params.id));
if (!item) {
return res.status(404).json({ error: "Item not found" });
}
res.json(item);
});
app.listen(port, "0.0.0.0", () => {
console.log(`Server listening on port ${port}`);
});Create package.json:
{
"name": "my-express-app",
"version": "1.0.0",
"description": "Express.js application deployed on Out Plane",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "^4.21.0"
},
"engines": {
"node": ">=20.0.0"
}
}Create Procfile (no file extension):
web: node app.jsThis tells Buildpacks how to start your application. The server must listen on port 8080.
Test your application locally:
node app.jsVisit http://localhost:8080 in your browser. You should see the JSON response.
Push this code to a GitHub repository, and you're ready to deploy.
Optional: Add a Dockerfile
If you prefer full control over the build process, create a Dockerfile:
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 8080
CMD ["node", "app.js"]With a Dockerfile, select Dockerfile as your build method in the next step. Without one, select Buildpacks and Out Plane handles everything automatically.
Deploy in 3 Steps
Step 1: Connect Your Repository
- Go to console.outplane.com
- Sign in with your GitHub account
- Select your Express.js repository from the list
Out Plane automatically detects Node.js applications and configures the build process using Buildpacks.
Step 2: Configure Your Application
Configure the following settings in the create application form:
Build Method
Select how Out Plane should build your application:
- Buildpacks (Recommended): Automatically detects Node.js and installs dependencies from
package.json. Uses thestartscript to run your application. - Dockerfile: Use this if you have a custom
Dockerfilein your repository for full control over the build process.
For most Express.js applications, Buildpacks is the easiest option.
Basic Settings
- Port: Set to
8080 - Branch: Select
mainor your preferred branch - Region: Choose the region closest to your users
Environment Variables (Optional)
If your application uses environment-specific configuration, add them here using the Add button or Raw Edit for bulk entry:
NODE_ENV=production
API_KEY=your-api-key-hereStep 3: Deploy
Click Deploy Application and watch the build process:
- Queued → Waiting for resources
- Building → Installing dependencies from
package.json - Deploying → Starting your Express.js application
- Ready → Your app is live
Once the status shows Ready, your application is live. You can find your application URL at the top of the deployment page. Click the URL to open your Express.js app in a new tab. SSL is automatically configured.
Production Best Practices
Use a Process Manager
For production environments, handle uncaught exceptions and graceful shutdowns properly:
process.on("SIGTERM", () => {
console.log("SIGTERM received. Shutting down gracefully...");
server.close(() => {
console.log("Process terminated");
process.exit(0);
});
});
process.on("SIGINT", () => {
console.log("SIGINT received. Shutting down...");
server.close(() => {
process.exit(0);
});
});Store the server instance so you can close it on shutdown:
const server = app.listen(port, "0.0.0.0", () => {
console.log(`Server listening on port ${port}`);
});Environment-Based Configuration
Keep sensitive data out of your codebase. Read all configuration from environment variables:
// Good - read from environment
const port = process.env.PORT || 8080;
const dbUrl = process.env.DATABASE_URL;
const apiKey = process.env.API_KEY;
// Bad - hardcoded values
const apiKey = "sk-12345";Security Middleware with Helmet
Add helmet to set secure HTTP headers:
npm install helmetconst helmet = require("helmet");
app.use(helmet());Helmet sets headers like X-Content-Type-Options, Strict-Transport-Security, and X-Frame-Options automatically.
CORS Configuration
If your API serves a frontend on a different domain, configure CORS:
npm install corsconst cors = require("cors");
app.use(
cors({
origin: ["https://yourfrontend.com"],
methods: ["GET", "POST", "PUT", "DELETE"],
})
);Trust Proxy Setting
When running behind Out Plane's load balancer, enable the trust proxy setting so Express correctly reads client IP addresses and X-Forwarded-* headers:
app.set("trust proxy", 1);This ensures req.ip returns the real client IP and req.protocol reflects the original HTTPS request.
Connecting a Database
Most Express.js applications need a database. Out Plane provides managed PostgreSQL:
- Go to Databases in the sidebar
- Click Create Database
- Select PostgreSQL version and region
- Copy the connection URL
Add the connection URL as an environment variable:
DATABASE_URL=postgres://user:password@host:5432/databaseUse it in your Express.js application with the pg package:
npm install pgconst { Pool } = require("pg");
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false },
max: 20,
idleTimeoutMillis: 30000,
});
app.get("/api/users", async (req, res) => {
try {
const result = await pool.query("SELECT * FROM users LIMIT 50");
res.json(result.rows);
} catch (err) {
console.error("Database query error:", err);
res.status(500).json({ error: "Internal server error" });
}
});Or with Prisma for a type-safe ORM approach:
npm install prisma @prisma/client
npx prisma initconst { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();
app.get("/api/users", async (req, res) => {
const users = await prisma.user.findMany({ take: 50 });
res.json(users);
});Custom Domain Setup
Replace the default .outplane.app URL with your own domain:
- Navigate to Domains
- Click Map Domain
- Enter your domain (e.g.,
api.yourdomain.com) - Add the DNS records shown to your domain registrar
SSL certificates are automatically provisioned once DNS propagates.
Monitoring Your Application
After deployment, monitor your Express.js application:
- Logs: View real-time application logs including request logs and errors
- Metrics: Track CPU, memory, and network usage
- HTTP Logs: Analyze incoming requests, response times, and status codes
Access these from the sidebar in your application dashboard.
Troubleshooting
Application Won't Start
Check the port configuration. Make sure you set the port to 8080 in the application settings. Your Express app must listen on the port from the PORT environment variable or default to 8080:
const port = process.env.PORT || 8080;Module Not Found Errors
Verify all dependencies are in package.json. Run npm install locally and confirm your package.json lists every required package under dependencies (not devDependencies for runtime modules).
500 Internal Server Error
Check your application logs. Navigate to Logs in the sidebar to see Node.js error messages and stack traces. Add error-handling middleware to catch unhandled errors:
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).json({ error: "Internal server error" });
});CORS Issues
Verify your CORS configuration. If your frontend cannot reach the API, check that the origin in your CORS middleware matches the frontend URL exactly. Mismatched protocols (http vs https) or trailing slashes cause CORS failures.
Memory Leaks
Monitor memory usage in Metrics. Common causes include unbounded caches, unclosed database connections, and event listeners that are never removed. Use --max-old-space-size in your start command if you need to increase the Node.js heap limit:
{
"scripts": {
"start": "node --max-old-space-size=512 app.js"
}
}Next Steps
Your Express.js application is now deployed and running in production. Here's what to explore next:
- Scale your application: Adjust instance types and auto-scaling settings for higher traffic
- Set up CI/CD: Enable automatic deployments on every git push
- Add monitoring: Integrate with external monitoring tools via Out Plane's metrics export
- Configure caching: Add Redis for session storage and API response caching
Summary
Deploying an Express.js application to Out Plane takes three steps:
- Connect your GitHub repository
- Configure port (8080), environment variables, and build method
- Deploy and get your live URL with automatic HTTPS
No server configuration, no manual SSL setup, no infrastructure management. Just push your code and go live.
Ready to deploy your Express.js application? Get started with Out Plane and receive $20 in free credit.