Azure Linux VM- no connection could be made because the target actively refused it

Hi, While trying to install a simple cowsay application, I am getting the below error in my cmd

Error: timeout - last error: dial tcp :22: connectex: No connection could be made because the target machine actively refused it.

Before apply I also get this warning:

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the “${ sequence from the start and the }”
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

and my Terraform version command give me this

Terraform v0.12.29

  • provider.azurerm v2.20.0

and the provision syntax is something like this

connection {

    host = "${azurerm_public_ip.myterraformpublicip.ip_address}"

    agent = false

    user = "azureuser"

    password = var.password

    timeout = "180s"

}

provisioner "file" {

    source      = "C:\\Users\\myname\\Downloads\\cowsayinstall.sh"

    destination = "/home/azureuser/cowsayinstall.sh"

}

provisioner "remote-exec" {

  inline = [

    "chmod +x /home/azureuser/cowsayinstall.sh"

  ]

}

Can anyone tell me what is wrong am i doing, if i remove the $ sign it will say no such host found. I checked in different sites its says terraform vesion, mine is already 12. What is the correct way?? has anyone provisioned it?

Hi @ankku,

Could you please share the configuration as it was after you “removed the $ sign”? I think your removal of the interpolation syntax might have been incomplete and thus the result didn’t do what you intended, but I can’t be sure without seeing exactly what configuration produced the “target machine actively refused it” message.

here it is and then it says that no such host found:
connection {
// host = “${azurerm_public_ip.myterraformpublicip.ip_address}”
host = azurerm_public_ip.myterraformpublicip.ip_address
agent = false
user = “azureuser”
password = var.password
timeout = “180s”

Thank @ankku!

This looks like valid Terraform syntax to me, so I guess this is failing because for some reason the computer where you are running Terraform can’t reach whatever IP address is returned from azurerm_public_ip.myterraformpublicip.ip_address.

Unfortunately that makes it probably an Azure-specific question and I’m not personally very familiar with Azure, so I don’t have any other ideas to share. I’ve moved this topic into the Azure provider category in the hope that the contributors there will be able to recognize what’s going on here and suggest how to fix it.