Introduction
In Terraform Enterprise (TFE) environments, you may need to create custom terraform-bundle files to include custom or community providers. This article addresses a connection refused error that can occur when TFE is unable to download a new custom bundle.
Problem
After configuring a new custom terraform-bundle, Terraform Enterprise fails to download it, and runs fail with the following error message in the logs.
Operation failed: failed fetching Terraform: failed downloading terraform: failed downloading "http://<ip>:<port>/<filename>.zip": GET http://<ip>:<port>/<filename>.zip giving up after 5 attempt(s): Get "http://<ip>:<port>/<filename>.zip": dial tcp <ip>:<port>: connect: connection refused
Prerequisites
- A custom
terraform-bundlefile hosted at a URL accessible to the TFE instance.
Cause
The Terraform Enterprise worker cannot establish a network connection to the web server hosting the custom terraform-bundle file. This is typically due to a firewall rule, incorrect IP address or port, or an issue with the web server itself.
Solutions
Solution 1: Verify Network Accessibility
The most direct solution is to ensure the TFE server can reach the web server hosting the bundle.
-
From the Terraform Enterprise server's command line, attempt to download the bundle using
curlto test network accessibility.$ curl -kL http://<ip>:<port>/<filename>.zip
- If the command fails with a
connection refusederror, work with your network or web server administrator to resolve the connectivity issue. The administrator must ensure that the TFE worker has a clear network path to the specified IP address and port. - After your administrator confirms the URL is accessible, create a new
terraform-bundleentry in the TFE settings and test it in a non-critical workspace to confirm the fix.
Solution 2: Implement a Temporary Workaround
If you cannot resolve the network issue immediately, you can roll back critical workspaces to a previously working terraform-bundle to unblock operations.
- In the settings for any affected workspaces, change the Terraform Version to a previously known-good custom bundle or a standard Terraform version included with your TFE installation.
- Save the settings and queue a new plan to confirm the workspace is operational again.
- Continue to work with your administrator to resolve the networking issue as described in Solution 1. Once resolved, you can update the workspaces to use the new bundle.
Outcome
After resolving the network connectivity issue, Terraform Enterprise will be able to download the new custom terraform-bundle successfully, and runs will proceed as expected.
Additional Information
- For more details on creating custom bundles, refer to the guide on how to build a custom terraform-bundle.