Tools: How to Deploy a Node.js App on Heroku in 2026

Tools: How to Deploy a Node.js App on Heroku in 2026

What You Need Before You Start

How to Deploy a Node.js App on Heroku

Step 1: Prepare Your App for Heroku

Step 2: Create and Connect Your Heroku App

Step 3: Set Environment Variables

Step 4: Deploy via Git Push

Step 5: Add a Database (Optional)

Common Heroku Errors and Why They Push Developers Away

H10: App Crashed

Port Binding Issues

Module Not Found

The Catch: Heroku Pricing in 2026

The Best and Fastest Way to Deploy a Node.js App in 2026

What Makes Kuberns Different

How to Deploy Your Node.js App on Kuberns

Step 1: Connect your GitHub repo

Step 2: Let the AI scan your app

Step 3: Review or skip

Step 4: Hit deploy

Step 5: Add extras from the dashboard

Conclusion You finished your Node.js app. It runs fine on localhost. Now you want it live and accessible to anyone with a link. Heroku has been the default answer for this for years. It is still a working option in 2026, but it is not the same platform it was when it had a free tier. Before you commit to it, it helps to understand exactly what the setup involves, where it tends to break, and what it actually costs. This guide walks you through the full Heroku deploy process for a Node.js app, step by step. At the end, there is a section on a faster path if the Heroku setup feels like more overhead than your project needs. Before running a single command, make sure you have these in place: If your package.json does not have a start script yet, add one: If you are comparing where to deploy before committing to Heroku, the best Heroku alternatives for developers in 2026 covers the full landscape with honest trade-offs.

_** Three things need to be in place before your first push goes through cleanly. Pin your Node.js version Add an engines field to your package.json. This tells Heroku exactly which Node version to use and prevents unexpected behavior from version mismatches: A Procfile is a plain text file (no extension) in your project root. It tells Heroku how to start your app: If your entry file is named something other than index.js, update accordingly. Use process.env.PORT for your port Heroku assigns a dynamic port at runtime. If you hardcode a port like 3000, your app will crash on deploy. Update your server to use: Log into Heroku via the CLI: This opens a browser window to authenticate. Once done, come back to your terminal. Replace your-app-name with something unique. If you skip the name, Heroku generates a random one. This command also automatically adds a heroku git remote to your local repo. Confirm the remote was added: You should see a heroku remote pointing to https://git.heroku.com/your-app-name.git. Never hardcode API keys, database URLs, or secrets in your code. Heroku provides config vars for this: To view all set variables: In your app code, access these with process.env.VARIABLE_NAME exactly as you would with a .env file locally. Stage and commit your changes if you have not already: If your default branch is master, use that instead. The terminal will show the build log in real time. A successful deploy ends with a line like: heroku openTo stream logs and verify everything is running correctly: If your Node.js app needs a PostgreSQL database, Heroku has a managed add-on: This provisions a database and automatically sets a DATABASE_URL config var on your app. In your Node.js code, connect using that variable: The mini plan is the lowest-cost option. Check Heroku’s add-on pricing page for current rates before provisioning. For teams deploying a Node.js backend alongside a frontend, how to deploy a full-stack app with AI from a single GitHub push covers the full-stack workflow in one place.**_ Heroku errors tend to show up right after your first successful deploy, which makes them especially frustrating. Here is what you will most likely hit and what each one signals. This is Heroku’s catch-all error for a process that exited unexpectedly. Common causes include a missing or wrong start script in package.json, a dependency that is not listed in package.json (works locally because it is already in node_modules, fails on Heroku because that folder is not committed), or a crash in your startup code before the server starts listening. To debug, run heroku logs --tail immediately after the crash. The actual error is almost always a few lines above the H10 line. The bigger point here: debugging a crashed dyno means reading logs in a terminal, cross-referencing config vars, and pushing fixes through git just to test a one-line change. That feedback loop gets slow fast. If you find yourself going through it repeatedly, it may be worth looking at a platform that gives you faster feedback and less manual config. Heroku dynamically assigns a port via process.env.PORT. If your app listens on a hardcoded port instead, Heroku cannot route traffic to it and the dyno shuts down with an R11 error. This is a fixable one-liner, but it is also the kind of thing Heroku never surfaces upfront, which means most developers hit it on their first deploy. This happens when a package your code depends on is missing from package.json. Locally it worked fine because the package was already in node_modules. On Heroku, only what is declared in package.json gets installed. Fix: run npm install package-name which updates package.json automatically, rather than manually editing the file. Each of these errors requires a new git commit and push just to test a fix. On a platform you are paying for, that friction compounds quickly. If you want a deploy workflow without these pain points, skip to the last section. If you have already decided Heroku is not the right fit, the top Heroku competitors and what makes each one different breaks down the alternatives worth considering. Heroku removed its free tier in November 2022. Here is what current pricing actually means for a Node.js app: Add-ons cost extra on top of that. PostgreSQL starts at a few dollars a month. You are also still managing buildpacks, Procfiles, dyno types, and config vars manually regardless of which tier you are on. You are paying for a platform that still requires a meaningful amount of manual configuration just to get a Node.js app running reliably. For a direct cost comparison between Heroku and its closest alternatives, Heroku vs Render vs Kuberns puts the pricing and feature differences side by side._** If what you actually want is your Node.js app live, stable, and accessible without spending half a day on config, Kuberns is the answer. Kuberns is an agentic AI deployment platform built on AWS. It reads your repository, detects your stack, configures your environment, and gets your app live in minutes. No Procfile. No CLI setup. No dyno types to manage. Here is what the AI agent handles automatically: Sign up at dashboard.kuberns.com, connect your GitHub account, and select the repository with your Node.js app. Kuberns AI reads your project structure, detects Node.js, identifies your entry point and dependencies, and sets up the build and run configuration automatically. You can review what the AI configured before deploying, or just hit deploy and let it handle everything. Either way takes under a minute. Kuberns builds your app, provisions infrastructure on AWS, and gives you a live HTTPS URL. The whole process takes under five minutes on a fresh project. Custom domain, environment variables, database, scaling rules all managed from a clean dashboard without touching a terminal. To see how Kuberns compares to other platforms on auto-deployment from GitHub, how to auto-deploy your apps from GitHub in one click walks through the exact workflow.

_** Deploying a Node.js app on Heroku in 2026 still works. The process is straightforward once you have the Procfile set up, the port configured correctly, and your dependencies in order. The CLI-based workflow gives you full control and the platform is mature and well-documented. The trade-off is that Heroku asks you to manage a fair amount of configuration manually, charges at least $5 to $7 a month for a dyno that still sleeps, and creates friction every time something breaks in production. If your goal is to get your Node.js app live fast and keep it running without the overhead, Kuberns handles all of that automatically. Connect your repo, let the AI set up your environment, and deploy in minutes. You can also check how this compares to the standard Node.js deployment guide or explore the full list of Heroku alternatives in 2026 if you are evaluating other platforms. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

"scripts": { "start": "node index.js" } "scripts": { "start": "node index.js" } "scripts": { "start": "node index.js" } "engines": { "node": "22.x" } "engines": { "node": "22.x" } "engines": { "node": "22.x" } web: node index.js web: node index.js web: node index.js const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); heroku login heroku login heroku login heroku create your-app-name heroku create your-app-name heroku create your-app-name git remote -v git remote -v git remote -v heroku config:set NODE_ENV=production heroku config:set API_KEY=your-actual-key heroku config:set DATABASE_URL=your-database-connection-string heroku config:set NODE_ENV=production heroku config:set API_KEY=your-actual-key heroku config:set DATABASE_URL=your-database-connection-string heroku config:set NODE_ENV=production heroku config:set API_KEY=your-actual-key heroku config:set DATABASE_URL=your-database-connection-string heroku config heroku config heroku config git add . git commit -m "Prepare for Heroku deploy" git add . git commit -m "Prepare for Heroku deploy" git add . git commit -m "Prepare for Heroku deploy" git push heroku main git push heroku main git push heroku main remote: Verifying deploy... done. remote: Verifying deploy... done. remote: Verifying deploy... done. heroku logs --tail heroku logs --tail heroku logs --tail heroku addons:create heroku-postgresql:mini heroku addons:create heroku-postgresql:mini heroku addons:create heroku-postgresql:mini const { Pool } = require('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false } }); const { Pool } = require('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false } }); const { Pool } = require('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false } }); - Node.js and npm installed on your machine (run node -v to confirm) - A Heroku account: create one at heroku.com. Note: you will need a paid plan to keep your app awake - Heroku CLI installed: download from the Heroku Dev Center for your OS - A package.json in your project root with a start script defined under scripts - A Git repository: Heroku deploys via git push, so your project needs to be a git repo - Eco dynos cost around $5 per month but sleep after 30 minutes of inactivity. Your app takes 20 to 30 seconds to wake on the next request. For anything you want to share with a client or demo to users, that cold start is a bad first impression. - Basic dynos at around $7 per month stay awake but give you a single instance with no autoscaling and no built-in metrics. - Standard dynos start at $25 per month for a proper always-on setup with horizontal scaling. - Stack detection: Kuberns reads your package.json and identifies your Node.js version, framework, and dependencies without any manual input - Zero config deploy: no Procfile, no buildpack selection, no port configuration. The AI figures out how to start your app - Automatic database provisioning: need PostgreSQL or MySQL? Kuberns provisions it and injects the connection string as an environment variable - SSL and custom domain: HTTPS is on by default. Point your domain and it handles the certificate - Always-on, no sleeping: your app stays up. No cold starts, no 30-second wake times on the cheapest plan - One-click rollbacks: if a deploy breaks something, roll back to the previous version from the dashboard in one click - Live logs and monitoring: everything you would get from heroku logs --tail, but in a dashboard with no terminal required - Up to 40% cheaper than direct AWS, with $14 in free credits to start