{"id":10976,"date":"2023-10-10T07:14:31","date_gmt":"2023-10-10T07:14:31","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=10976"},"modified":"2023-10-10T07:14:33","modified_gmt":"2023-10-10T07:14:33","slug":"terraform-error","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/","title":{"rendered":"Terraform Error:"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Error: imeout &#8211; last error: unknown error<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>azurerm_windows_virtual_machine.main: Still creating... &#91;6m30s elapsed]\r\nazurerm_windows_virtual_machine.main: Still creating... &#91;6m40s elapsed]\r\n\u2577\r\n\u2502 Error: file provisioner error\r\n\u2502\r\n\u2502   with azurerm_windows_virtual_machine.main,\r\n\u2502   on pro.tf line 144, in resource \"azurerm_windows_virtual_machine\" \"main\":\r\n\u2502  144:    provisioner \"file\" {\r\n\u2502\r\n\u2502 timeout - last error: unknown error Post \"https:\/\/20.124.192.65:5986\/wsman\": dial tcp 20.124.192.65:5986: connectex: A connection attempt\r\n\u2502 failed because the connected party did not properly respond after a period of time, or established connection failed because connected host\r\n\u2502 has failed to respond.\r\n\u2575\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are a few possible reasons for this error:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The virtual machine is not yet running.<\/li>\n\n\n\n<li>The WinRM service is not running on the virtual machine.<\/li>\n\n\n\n<li>The WinRM port is blocked on the virtual machine.<\/li>\n\n\n\n<li>There is a network connectivity issue between Terraform and the virtual machine.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To troubleshoot this error, you can try the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify that the virtual machine is running.<\/li>\n\n\n\n<li>Verify that the WinRM service is running on the virtual machine. You can do this by running the following command on the virtual machine:<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nGet-Service WinRM\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">If the WinRM service is not running, you can start it by running the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nStart-Service WinRM\n\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Verify that the WinRM port is not blocked on the virtual machine. You can do this by running the following command on the virtual machine:<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nTest-NetConnection -ComputerName 20.124.192.65 -Port 5986\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">If the connection test fails, you need to open the WinRM port on the virtual machine.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify that there is network connectivity between Terraform and the virtual machine. You can do this by running a ping test from Terraform to the virtual machine.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you are still unable to resolve the error, you can try using a different connection type, such as SSH.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some additional tips for troubleshooting WinRM connectivity issues:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make sure that the WinRM firewall exceptions are enabled on the virtual machine.<\/li>\n\n\n\n<li>Make sure that the WinRM service is listening on the correct port. By default, WinRM listens on port 5986.<\/li>\n\n\n\n<li>Make sure that the WinRM service is configured to use HTTP or HTTPS.<\/li>\n\n\n\n<li>Make sure that the WinRM service is configured to allow remote connections.<\/li>\n\n\n\n<li>Make sure that the WinRM service is configured to use the correct authentication method. By default, WinRM uses NTLM authentication.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The error message indicates that Terraform is having trouble connecting to the newly created Azure VM over port 5986, which is the port for secure WinRM (Windows Remote Management). Terraform uses WinRM to run the provisioners, such as the file provisioner in your case.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some troubleshooting steps and considerations to resolve the error:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Ensure WinRM is Enabled<\/strong>: The Azure VM must have WinRM enabled and properly configured to accept connections. The default Azure Windows Server images often have WinRM enabled, but ensure it&#8217;s set up correctly.<\/li>\n\n\n\n<li><strong>Security Rules<\/strong>: Double-check the network security group (NSG) rules to ensure port 5986 is open for inbound traffic. From the Terraform code you provided earlier, it seems you&#8217;ve set this up, but it&#8217;s worth double-checking in the Azure portal or using the Azure CLI.<\/li>\n\n\n\n<li><strong>Self-Signed Certificates<\/strong>: If you&#8217;re using self-signed certificates for WinRM (which is often the case with default Azure images), ensure that the <code>insecure<\/code> option is set to <code>true<\/code> for the connection block in the VM resource. You&#8217;ve already done this in the provided code, but it&#8217;s a common oversight.<\/li>\n\n\n\n<li><strong>VM Availability<\/strong>: Sometimes, the VM might take a while to become fully operational after creation. This includes network interfaces being properly initialized and services starting up. While Terraform does wait for the VM to report as &#8220;running&#8221;, there can still be a delay before everything is ready. One option could be to introduce a deliberate delay using a <code>local-exec<\/code> provisioner that simply waits for a few minutes before proceeding.<\/li>\n\n\n\n<li><strong>Azure VM WinRM Extension<\/strong>: Azure provides an extension to ensure WinRM is correctly configured on the VM. Consider using the <code>azurerm_virtual_machine_extension<\/code> resource to ensure WinRM is set up correctly. This can be used to enable and configure WinRM on the VM after it&#8217;s created but before you try to use it.<\/li>\n\n\n\n<li><strong>Connection Block<\/strong>: Make sure your connection block has the correct configuration. From the code you provided, it seems mostly correct, but make sure the host and other parameters are correct at runtime.<\/li>\n\n\n\n<li><strong>Testing Connectivity<\/strong>: You can test WinRM connectivity from your local machine or another machine using PowerShell or other WinRM clients. This can help determine if the issue is with Terraform or with the VM\/network itself.<\/li>\n\n\n\n<li><strong>Review VM Logs<\/strong>: If possible, review the logs of the VM. You can do this by logging into the VM through the Azure portal or by using another method like RDP. The logs might provide clues if there are any issues with the VM or the WinRM service.<\/li>\n\n\n\n<li><strong>Terraform Provider Version<\/strong>: Ensure you&#8217;re using a recent version of the <code>azurerm<\/code> provider. Sometimes bugs or issues are resolved in newer versions.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Error: imeout &#8211; last error: unknown error Solution There are a few possible reasons for this error: To troubleshoot this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10976","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Terraform Error: - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Terraform Error: - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Error: imeout &#8211; last error: unknown error Solution There are a few possible reasons for this error: To troubleshoot this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-10T07:14:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-10T07:14:33+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"Terraform Error:\",\"datePublished\":\"2023-10-10T07:14:31+00:00\",\"dateModified\":\"2023-10-10T07:14:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/\"},\"wordCount\":726,\"commentCount\":0,\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/\",\"name\":\"Terraform Error: - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2023-10-10T07:14:31+00:00\",\"dateModified\":\"2023-10-10T07:14:33+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/terraform-error\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Terraform Error:\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Terraform Error: - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/","og_locale":"en_US","og_type":"article","og_title":"Terraform Error: - scmGalaxy","og_description":"Error: imeout &#8211; last error: unknown error Solution There are a few possible reasons for this error: To troubleshoot this [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/","og_site_name":"scmGalaxy","article_published_time":"2023-10-10T07:14:31+00:00","article_modified_time":"2023-10-10T07:14:33+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"Terraform Error:","datePublished":"2023-10-10T07:14:31+00:00","dateModified":"2023-10-10T07:14:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/"},"wordCount":726,"commentCount":0,"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/","name":"Terraform Error: - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2023-10-10T07:14:31+00:00","dateModified":"2023-10-10T07:14:33+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/terraform-error\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Terraform Error:"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=10976"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10976\/revisions"}],"predecessor-version":[{"id":10977,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10976\/revisions\/10977"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=10976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=10976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=10976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}