Using Variables in a Heroku Procfile

Image for post
Image for post

A Heroku Procfile has access to the config variables set for an app. This can be used to make the Procfile dynamic.

In Heroku, an app’s config variables can be set in two ways.

1.) Using the web interface to navigate to the app’s settings tab:

Image for post
Image for post

2.) With the following command:

heroku config:set CONFIG_VAR_NAME=var_value -a appName

These variables can now be access by prefixing the variable name with $. This can be useful in a few ways. For instance, let’s say that we want to dynamically set the heap size of a web server dynamically. We could first create a HEAP_SIZE configuration variable and then access it in the Procfile.

web: node --max_old_space_size=$HEAP_SIZE server.js

To learn more about a Procfile, visit

That’s it!

Written by

Software Developer. Focused. Determined. Unstoppable.

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