Skip to main content

Command: logout

The terraform logout command removes locally-stored credentials for a specified hostname.

Usage

terraform logout [hostname]
If no hostname is provided, the default hostname is app.terraform.io. This command removes the stored API token for the specified hostname from your local credentials file.
The API token is only removed from local storage, not destroyed on the remote server. The token will remain valid on the server until manually revoked through the web interface.

What Gets Removed

The terraform logout command removes credentials from your local CLI configuration file, typically located at:
  • On Linux and macOS: ~/.terraform.d/credentials.tfrc.json
  • On Windows: %APPDATA%\terraform.d\credentials.tfrc.json
If you’re using a credentials helper, the command will remove the credentials from that helper instead.

Example

Log out from HCP Terraform:
terraform logout
Log out from a Terraform Enterprise instance:
terraform logout app.terraform.example.com

Revoking Tokens

To fully revoke a token (making it invalid on the server), you must manually revoke it through the web interface:

Manually Configured Credentials

If credentials are manually configured in a CLI configuration file (not the default credentials file), terraform logout will display an error. You must manually remove the credentials block from the configuration file.

Build docs developers (and LLMs) love