How to Deploy A Golang App to Heroku.

This is a step by step tutorial on how to deploy a Golang app on Heroku.


  1. Heroku Account
  2. Heroku CLI
  3. Golang v1.14 and above

Step 1.

Create a Heroku account using your email and password or log in if you already have an account.

Download the Heroku CLI by running the command below on Mac OS

$ brew tap heroku/brew && brew install heroku

Or go-to to install on Windows.

Login to Heroku from your terminal using the command

$ heroku login

This will open your web browser to complete the login flow.

Step 2.

Create Procfile by running

$ touch Procfile

or just create it from directory.

Run echo “web: [directory]” > Procfile replace [directory] e.g

$ echo “web: currency” > Procfile

Step 3.

Generate a go.mod file using go mod init[user_name]/[project_name] e.g.

$ go mod init

Step 4.

Set variable names in .env file e.g. PORT=8080 using

$ heroku config:set PORT=8080

You can also set other variables using this command.

Step 5.

Commit your code using the following commands

$ git init
$ git add . && git commit -m "Deploying to Heroku"

Step 6.

Create a Heroku application using heroku create [project_name] e.g.

$ heroku create go-currency
$ git push heroku master

You can then proceed to test your app using https://[project_name] i.e.

If you encounter any error during any of these processes, do not hesitate to comment or reach out Kehinde A. Olawuwo. Thank you.




Back-end Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tuples in Programming Language

Design problem- Structural analysis

SDM 1.0 Platform for Software Delivery

Capturing E-Signatures in AssetSonar

(A better way to) Monitor Your Parity Substrate Node

Rust Simple server

Aminata Gadio Final Project — Web scraping

Image result for web scraping

Adding custom cops & auto-correct to RuboCop

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kehinde A. Olawuwo

Kehinde A. Olawuwo

Back-end Developer

More from Medium

Detect Objects Including Types and Locations in an Image using Go

User Creation And Authentication in Golang Part 1

Part 2: Grpc Proto Code Generation Using Protoc for Message and Services

Building a Simple REST API in Go With Gorilla/Mux