[{"data":1,"prerenderedAt":171},["ShallowReactive",2],{"/2025/11/30-error-installing-aws-codedeploy-agent-in-windows-server-2016":3},{"id":4,"title":5,"body":6,"date":162,"description":67,"extension":163,"meta":164,"navigation":165,"path":166,"robots":167,"seo":168,"stem":169,"__hash__":170},"posts/2025/11/30 error-installing-AWS-CodeDeploy-Agent-in-Windows-Server-2016.md","30 Error Installing AWS CodeDeploy Agent In Windows Server 2016",{"type":7,"value":8,"toc":159},"minimark",[9,18,25,28,31,33,36,49,51,54,68,70,81,83,86,95,97,100,108,111,119,122,124,127],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"error-installing-aws-codedeploy-agent-in-windows-server-2016","Error Installing AWS CodeDeploy Agent in Windows Server 2016",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 6/8/2020.",[26,27],"br",{},[22,29,30],{},"It has been a while since I added an EC2 instance to our CI/CD pipeline. And this time, I need to allow a Windows Server 2016 to receive artifacts from AWS CodeDeploy by installing the agent. And installing the CodeDeploy agent is not straight forward.",[26,32],{},[22,34,35],{},"I followed the instructions to install using Windows PowerShell:",[22,37,38],{},[39,40,43],"span",{"className":41},[42],"text-blue-600",[44,45,46],"a",{"href":46,"rel":47},"https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-windows.html#codedeploy-agent-operations-install-windows-powershell",[48],"nofollow",[26,50],{},[22,52,53],{},"It went smoothly until it tried to start the windows service which failed with the following error message:",[55,56,57],"code-block",{},[58,59,64],"pre",{"className":60,"code":62,"language":63},[61],"language-text","Service 'CodeDeploy Host Agent Service' (codedeployagent) failed to start. \nVerify that you have sufficient privileges to start system services\n","text",[65,66,62],"code",{"__ignoreMap":67},"",[26,69],{},[22,71,72,73,80],{},"The error message can be found in the log file which is located at:\n",[65,74,79],{"className":75},[76,77,78],"bg-gray-200","p-2","rounded","C:\\temp\\host-agent-install-log",".",[26,82],{},[22,84,85],{},"The following article helps me solving the installation issue:",[22,87,88],{},[39,89,91],{"className":90},[42],[44,92,93],{"href":93,"rel":94},"https://github.com/aws/aws-codedeploy-agent/issues/189",[48],[26,96],{},[22,98,99],{},"Basically, we need to add Windows Defender exclusions for the installation and execution folders. In my case, it will be:",[55,101,102],{},[58,103,106],{"className":104,"code":105,"language":63},[61],"Add-MpPreference -ExclusionPath (\"C:\\ProgramData\\Amazon\\CodeDeploy\",\"$env:windir\\Temp\")\n",[65,107,105],{"__ignoreMap":67},[22,109,110],{},"The following worked in Windows Server 2016 but somehow didn't work in 2019:",[55,112,113],{},[58,114,117],{"className":115,"code":116,"language":63},[61],"Add-MpPreference -ExclusionPath (\"C:\\temp\", \"C:\\ProgramData\\Amazon\\CodeDeploy\") \n",[65,118,116],{"__ignoreMap":67},[22,120,121],{},"Updates\nJune 18, 2020\nThe last time I checked, it is no longer an issue in the following AMI:\nWindows_Server-2016-English-Full-Base-2020.06.10",[26,123],{},[22,125,126],{},"November 25, 2020\nIt happened to me again on Windows Server 2019. This time the EC2 is in private subnet, so I also checked the following:",[128,129,130,134,141,144],"ul",{},[131,132,133],"li",{},"Permission attached to EC2 instance profile",[131,135,136,137],{},"Access to endpoints:\n",[44,138,139],{"href":139,"rel":140},"https://stackoverflow.com/questions/48023692/aws-codedeploy-not-working-in-private-vpc",[48],[131,142,143],{},"Event Viewer > Application",[131,145,146,147,151,152],{},"Event Viewer > System. I noticed the following error message:\n",[65,148,150],{"className":149},[76,77,78],"A timeout was reached (30000 milliseconds) while waiting for the CodeDeploy Host Agent Service service to connect.","\nThe command above still worked, but need a slight change. Along with that, extending the timeout in the following article might help.\n",[39,153,155],{"className":154},[42],[44,156,157],{"href":157,"rel":158},"https://kevsoft.net/2017/10/02/codedeploy-agent-failing-to-start.html",[48],{"title":67,"searchDepth":160,"depth":160,"links":161},2,[],"2025-11-30T00:00:00.000Z","md",{},true,"/2025/11/30-error-installing-aws-codedeploy-agent-in-windows-server-2016",null,{"title":5,"description":67},"2025/11/30 error-installing-AWS-CodeDeploy-Agent-in-Windows-Server-2016","Fddgukpf09outU3251EDLR9E-b_3dilaYcRaxqQTHvM",1785167452382]