Problem
You experience an error similar to the one displayed below during a workspace execution.
Error: Error accessing remote module registry Failed to retrieve available versions for module "XXX" (modules/base-infrastructure/main.tf:1) from app.terraform.io: error looking up module versions: 429 Too Many Requests.
Cause
By default, requests to the Terraform Enterprise and HCP Terraform API from a single user or IP address are limited to 30 requests per second. During runs that involve many module lookups, this limit can be exceeded, resulting in a 429 Too Many Requests error.
Solutions
The solution depends on which Terraform edition you are using.
Solution 1: Increase API Rate Limit in Terraform Enterprise
Terraform Enterprise site administrators can increase the API rate limit.
- Access the Admin settings page. For guidance, refer to the documentation on accessing the Admin interface.
- Note: For Terraform Enterprise release v202106-1 or lower, the option is named Site Admin in the user avatar dropdown menu.
- Navigate to Settings > API Rate Limiting.
- Increase the rate limit value. Doubling the value to 60 is a reasonable first step for periodic errors. Depending on your workload or the number of concurrent runs, you may need to set a higher value.
Solution 2: Acknowledge Rate Limit in HCP Terraform
The API rate limit for HCP Terraform is a global setting of 30 requests per second that applies to all users and cannot be increased. This policy ensures service stability and prevents resource monopolization. If you encounter this limit, you may need to refactor your configuration to reduce the number of module registry lookups or introduce delays between operations.