Shell

A terminal in a running web service, in your browser.

The Shell page opens a terminal inside a running web service. Use it to look around, check files and settings, and run one-off commands such as a database migration.

Changes in the shell are temporary

Anything you change in the shell is lost when the service deploys, restarts, crashes or runs out of memory. This includes packages you install and files you create or edit. Make lasting changes in your repository instead.

Open a shell

  1. Open the web service.
  2. Choose Shell in its sidebar.

The terminal connects by itself, and the status at the top shows when it's connected. The shell is available only while the service is Live. Until then, the page shows Shell not available.

The shell starts bash if the service's image has it, and sh otherwise. It has the same environment variables as your service. An image with no shell at all can't open a terminal.

Session length

A session ends after 30 minutes. Click Reconnect to start a new one. If the connection drops, the terminal tries to reconnect by itself and shows Reconnect if it can't.

Make changes that last

The shell runs inside your live service, so what you run there shares its memory and CPU, and a command that uses too much memory restarts the service. The service is replaced on every deploy and restart, so to keep a change:

You want toDo this
Install an operating system packageInstall it in your Dockerfile.
Change code or configuration filesCommit the change to your repository and deploy.
Change a settingUse an environment variable.
Keep files your app writesStore them in a storage service bucket.
Keep dataStore it in a Postgres database or key value store.

Workers, cron jobs and databases

Only web services have a shell. To connect to a Postgres database from your own computer, turn on public access or use private access, and connect with psql. You can also run psql from a web service's shell if the service's image includes it.