CraftedTemplate
Blog How to Deploy a Website on Heroku (Step-by-Step Tutorial)

How to Deploy a Website on Heroku (Step-by-Step Tutorial)

9/30/2025 • Festus Ayomike
How to Deploy a Website on Heroku (Step-by-Step Tutorial)

Introduction

Heroku is a platform-as-a-service (PaaS) that lets you deploy web apps and APIs without managing servers. While it’s not just for static sites, it’s great for Node.js, Python, and backend projects.

This guide shows you how to deploy a project to Heroku step by step.

Why Use Heroku?

  • Easy Git-based deployment (git push heroku main)

  • Free SSL included

  • Works for Node.js, Python, Ruby, Java, and more

  • Add-ons for databases, caching, etc.

Step 1: Install the Heroku CLI

(batchfile)
npm install -g heroku

Or download it.

Login:

(batchfile)
heroku login

Step 2: Prepare Your Project

Make sure your app has:

  • A package.json with a start script for Node.js

(json)
"scripts": {
  "start": "node index.js"
}
  • Or a Procfile (Heroku uses this to run your app):

(batchfile)
web: node index.js

Step 3: Create a Heroku App

(batchfile)
heroku create my-project-name

This gives you a URL like:

https://my-project-name.herokuapp.com

Step 4: Deploy with Git

Push your code to Heroku:

(batchfile)
git push heroku main

Heroku will build and start your app automatically.

Step 5: Open Your App

(batchfile)
heroku open

You’ll see your project live.

Optional: Add a Custom Domain

(batchfile)
heroku domains:add www.mywebsite.com

Update your DNS to point to the Heroku hostname provided.

Troubleshooting

  • App crashed? Run:

(batchfile)
heroku logs --tail
  • Wrong buildpack? Set it manually:

(batchfile)
heroku buildpacks:set heroku/nodejs
  • Free dyno sleeping? Heroku’s free tier sleeps after inactivity. Upgrade for always-on.

Conclusion

Heroku is excellent for full-stack or backend projects that need more than just static hosting.

Next, we’ll look at Hostinger, one of the most popular shared hosting providers.