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
npm install -g heroku
Or download it.
Login:
heroku login
Step 2: Prepare Your Project
Make sure your app has:
- A
package.json
with astart
script for Node.js
"scripts": {
"start": "node index.js"
}
- Or a
Procfile
(Heroku uses this to run your app):
web: node index.js
Step 3: Create a Heroku App
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:
git push heroku main
Heroku will build and start your app automatically.
Step 5: Open Your App
heroku open
You’ll see your project live.
Optional: Add a Custom Domain
heroku domains:add www.mywebsite.com
Update your DNS to point to the Heroku hostname provided.
Troubleshooting
- App crashed? Run:
heroku logs --tail
- Wrong buildpack? Set it manually:
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.