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

Code · batchfile
npm install -g heroku

Or download it.

Login:

Code · batchfile
heroku login

Step 2: Prepare Your Project

Make sure your app has:

  • A package.json with a start script for Node.js
Code · json
"scripts": {
  "start": "node index.js"
}
  • Or a Procfile (Heroku uses this to run your app):
Code · batchfile
web: node index.js

Step 3: Create a Heroku App

Code · 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:

Code · batchfile
git push heroku main

Heroku will build and start your app automatically.

Step 5: Open Your App

Code · batchfile
heroku open

You’ll see your project live.

Optional: Add a Custom Domain

Code · batchfile
heroku domains:add www.mywebsite.com

Update your DNS to point to the Heroku hostname provided.

Troubleshooting

  • App crashed? Run:
Code · batchfile
heroku logs --tail
  • Wrong buildpack? Set it manually:
Code · 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.