Problem
The Terraform Enterprise (TFE) application fails to start. The Replicated console displays a "waiting on components to start" message before failing with the following error.
Container ptfe_postgresql_setup failed: Timeout waiting for event Postgres setup
Running the replicatedctl app status command on the Terraform Enterprise server may also display this error.
Cause
This error occurs when the Terraform Enterprise application cannot resolve the hostname of its PostgreSQL database server. The ptfe-postgresql-setup container logs show a DNS resolution failure.
psql: error: could not translate host name "tfe-postgres" to address: Name or service not known
The PostgreSQL hostname is not resolvable from within the ptfe-postgresql-setup container. This may be due to an external DNS configuration issue or a problem with Docker's internal DNS resolution.
Solutions
Solution 1: Verify External Database Connectivity
Confirm that the Terraform Enterprise server can resolve and connect to the PostgreSQL server's hostname or IP address. In the following commands, replace $tfe-postgres with the IP address or fully qualified domain name (FQDN) of your PostgreSQL server.
-
Test the connection to the PostgreSQL server port.
$ nc -vz $tfe-postgres 5432
-
Verify DNS resolution for the PostgreSQL server.
$ nslookup $tfe-postgres
If these commands fail, you must resolve the underlying network or DNS issue before Terraform Enterprise can start.
Solution 2: Troubleshoot Internal Container DNS
If external connectivity is working, the issue may be with Docker's internal DNS resolution. You can test connectivity from within the container and restart services to re-establish DNS.
-
SSH to the Terraform Enterprise instance and start a shell session inside the
ptfe-postgresql-setupcontainer.$ docker exec -it ptfe-postgresql-setup bash
- From inside the container, attempt to connect to the database using
psql. You can find connection details in the container's environment variables. For more detailed instructions, refer to the guide on how to connect to PostgreSQL from container. - If the connection fails, check that the container's
/etc/resolv.conffile contains the Docker DNS resolver, which is typically127.0.0.11. -
If DNS issues persist, restart the Docker and Replicated services to re-initialize the container networking.
a. Stop the Replicated services.
$ replicatedctl app stop $ systemctl stop replicated replicated-ui replicated-operator
b. Stop the Docker service.
$ systemctl stop docker
c. Start the Docker service.
$ systemctl start docker
d. Start the Replicated services.
$ systemctl start replicated replicated-ui replicated-operator $ replicatedctl app start
Outcome
Once the Terraform Enterprise server and its containers can successfully resolve the FQDN of the PostgreSQL database server, the application components will start correctly and become available.