Terragrunt shows this error when it cannot determine the specific exit code from an underlying command failure. The actual error is usually displayed before this message, making it crucial to look at the full error output to identify the root cause.
The "Unable to determine underlying exit code" error is a catch-all message that Terragrunt displays when an underlying command (typically Terraform) fails in a way that Terragrunt cannot translate to a specific exit code. This is not the actual error itselfβit's Terragrunt's way of saying "something went wrong, but I couldn't figure out exactly what." The real problem is always indicated by the error message that appears immediately before this line. This could be a configuration error, a binary compatibility issue, a missing file, deprecated command syntax, or various other problems. Understanding this pattern is key to troubleshooting: always look up, not at the final error message.
The key to solving this error is examining the error message that appears before the "Unable to determine underlying exit code" line. Copy the entire error output and focus on understanding the first error message shown.
Run your Terragrunt command and carefully read what comes before the exit code error:
terragrunt plan
# Look at ALL output, not just the last lineCommon preceding error messages include:
- "The run-all plan command is no longer supported"
- "Only one terraform block is allowed"
- "fork/exec /usr/local/bin/terraform: exec format error"
- "Error reading file at path"
- "Could not parse output from terragrunt config"
Terragrunt changed its CLI syntax. Update any deprecated run-all commands to the new run --all format.
Old (deprecated):
terragrunt run-all plan
terragrunt run-all applyNew (correct):
terragrunt run --all plan
terragrunt run --all applyIf you're using scripts or CI/CD pipelines, search for 'run-all' and replace with 'run --all'.
Ensure your terragrunt.hcl file has correct syntax and only one terraform block. Run:
terragrunt validateCheck for:
- Duplicate terraform blocks (only one allowed)
- Missing required fields in remote_state configuration (e.g., project for GCS)
- Syntax errors or typos in configuration blocks
- Improperly nested blocks
Fix any configuration issues and try again.
Get more information about what Terragrunt is doing by running with debug logging enabled:
terragrunt --terragrunt-log-level debug planThis will show detailed logs that reveal exactly where the failure occurs. Save the output to a file for easier review:
terragrunt --terragrunt-log-level debug plan 2>&1 | tee debug.logLook for the first error or warning in the debug output to understand the root cause.
If you're running in a container or unusual environment, ensure:
1. Terraform and Terragrunt binaries match your system architecture:
file /usr/local/bin/terraform
# Should show: ELF 64-bit LSB executable, x86-64 (or matching your arch)2. Check for problematic environment variables:
export AWS_CSM_ENABLED=false # Disable AWS client-side monitoring
terragrunt plan3. Verify your PATH includes the correct binary locations:
which terraform
which terragruntEnsure you're running commands from a directory containing terragrunt.hcl and that all referenced modules are accessible:
# Verify terragrunt.hcl exists in current directory
ls -la terragrunt.hcl
# If not, navigate to the correct directory or create a root terragrunt.hcl
cd /path/to/terragrunt/modules
# Try running from the directory with terragrunt.hcl
terragrunt planIf modules are downloaded from Git, verify:
- Git credentials are configured correctly
- URLs are formatted properly (e.g., 'github.com/org/repo.git//')
- Network connectivity to Git repositories exists
When Terragrunt wraps Terraform execution, it uses exit codes to determine success or failure. However, in certain edge cases (particularly when dealing with unusual system configurations, container environments, or specific error conditions), Terragrunt cannot parse the underlying process exit code. Rather than guess, it reports this uncertainty with the "Unable to determine underlying exit code" message.
For debugging in CI/CD environments like GitHub Actions, always capture the full stdout and stderr output. The actual error is almost always present in the lines immediately before this message. Tools like Terragrunt error handling blocks and the errors configuration can help manage failures gracefully without relying on exit code determination.
If you consistently encounter this error in a Docker container, ensure you're using multi-stage builds or images with the correct architecture binaries. Using alpine:latest without proper multi-arch setup is a common culprit.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform