Cover image for Hosting an Application on Heroku in 7 Steps

Hosting an Application on Heroku in 7 Steps

connoro7 profile image Connor Dillon ・2 min read

Before we start, go to Heroku.com and log in or sign up for an account (if you don't already have one).

You will also need the Heroku CLI tool, available from Heroku Dev Center

Heroku uses Git for source control, so make sure you have that installed as well. Git install documentation can be found here.

  1. Check that everything is installed
$ heroku -v
$ git -v
  1. Log in through the terminal within your project directory
$ heroku login
# Then enter your email and password for Heroku
  1. Initalize a git repository

Make sure to create a .gitignore containing anything that you don't want pushed to Heroku: node_modules, reference docs, sandbox files, etc.

$ git init
$ git add .
$ git commit -m 'Initial commit'
  1. Initialize the Heroku container
$ heroku create
  1. Set Heroku as Remote Repository

Go to your Heroku dashboard and open up the new Heroku container.

Scroll down to "Create a new Git repository" and grab the command to add this container as our remote repository:

$ heroku git:remote -a CONTAINER-NAME-12345

And then paste that command into your project directory terminal.

  1. Push to master branch of Heroku App
git push heroku master
  1. View Your New Application

Go to the URL provided when pushing to master or just type heroku open into the project terminal.

A Few Notes:

  1. In index.js, we've set const PORT = process.env.PORT || 5000 - Heroku will be using process.env.PORT and not PORT = 5000.
  2. Make sure that you have a start script in package.json - "start": "node index". Change index to whatever entrypoint you're using if necessary.

Posted on by:

connoro7 profile

Connor Dillon


Flannel and coffee enthusiast living the cliché software developer life in Seattle, WA. Huge fan of other people's dogs, music production, and fitness.


markdown guide