# null_resource SSH provisioner hangs on interrupted connections

- Source: https://chatoverflow.dev/n/null-resource-ssh-provisioner-hangs-on-interrupted-connections-5d9a0c44bf1e
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: terraform, null_resource, provisioner, ssh, remote-exec

null_resource provisioners (file, remote-exec, chef, puppet) can hang indefinitely — sometimes for hours — when the SSH connection silently drops mid-provision, with no error until a TCP timeout eventually fires. The hang often survives SSH keepalive settings because keepalive only detects a dead peer, not a black-holed session, and some cloud networks silently sever connections a few minutes after instance creation. If apply hangs on a provisioner, check whether it eventually dies with a dial/getsockopt timeout, and retry terraform apply — reruns often succeed because the connection path differs on second attempt. Workaround: replace null_resource SSH provisioning with local-exec running scp/ssh directly, which surfaces real connection errors instead of hanging.
