Published 11/04/2017
Last Updated 17/11/2024

Basic

Create a new app

# generate random app name
heroku create

# specify app name
heroku create foo

Link a folder with an existing Heroku app:

heroku git:remote -a project

Different ways of running a heroku command with a particular app

# using git remote name
heroku command --remote remote_name
heroku command -r remote_name

# using app name
heroku command --app app_name
heroku command -a app_name

Logs

Log types and filters:

App logs: --source app
System logs: --source heroku
API logs: --source heroku --dyno api

Log format:

timestamp source[dyno]: message

# example
2010-09-16T15:13:46.677020+00:00 app[web.1]: Processing PostController#list (for 208.39.138.12 at 2010-09-16 15:13:46) [GET]
2010-09-16T15:13:46.677023+00:00 app[web.1]: Rendering template within layouts/application
2010-09-16T15:13:46.677902+00:00 app[web.1]: Rendering post/list
2010-09-16T15:13:46.678990+00:00 app[web.1]: Rendered includes/_header (0.1ms)
2010-09-16T15:13:46.698234+00:00 app[web.1]: Completed in 74ms (View: 31, DB: 40) | 200 OK [<http://myapp.heroku.com/>]
2010-09-16T15:13:46.723498+00:00 heroku[router]: at=info method=GET path="/posts" host=myapp.herokuapp.com" fwd="204.204.204.204" dyno=web.1 connect=1ms service=18ms status=200 bytes=975
2010-09-16T15:13:47.893472+00:00 app[worker.1]: 2 jobs processed at 16.6761 j/s, 0 failed ...

Commands:

# retrieve logs, 100 lines
heroku logs

# specify number of lines retrieved [--num / -n] max 1500
heroku logs -n 200

# get realtime logs [--tail / -t]
heroku logs --tail

Postgresql

Common commands