title: How to avoid the configuration error while using AWS API Gateway with VPC Link?
body: <p>I have created the VPC Link using the Network Load Balancer (NLB) as per the AWS documentation and attached the same with the API Gateway resource / method. But it throws "Internal Server Error" when accessing the "Invoke URL" and displays this error while testing: "Execution failed due to configuration error: There was an internal error while executing your request".</p>
  
  <p><strong>Procedure I followed:</strong></p>
  
  <p>1) Created Network Load Balancer : </p>
  
  <ul>
  <li>Load Balancer Scheme: Internal</li>
  <li>Load Balancer Protocol / port : TCP / 80</li>
  <li>Availability Zone : Created VPC with CIDR "10.0.0.0/16" and public subnet with CIDR "1XX.XX.0.0/16".</li>
  <li>Target Group : Protocol / Port / Target Type - TCP / 80 / Instance</li>
  <li>No Target Registration.</li>
  <li>Launched NLB.</li>
  </ul>
  
  <p>2) Created VPC Link in API Gateway using the newly created NLB.</p>
  
  <p>3) Created new API :</p>
  
  <ul>
  <li>Method : Get</li>
  <li>Integration Type : VPC Link</li>
  <li>Use Proxy Integration : True</li>
  <li>VPC Link : ${stageVariables.vpcLinkId}</li>
  <li>Endpoint URL : "My ec2 instance URL with port" (Ex: <a href="http://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com:3000" rel="noreferrer">http://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com:3000</a>)</li>
  <li>Created API resource.</li>
  </ul>
  
  <p>4) Deployed the selected API using the "Deploy API" action and newly created stage.</p>
  
  <p>5) Configured the "vpcLinkId" in the "Stage Variables" section.</p>
  
  <p>Now if I hit the "Invoke URL", the web page displays " {"message": "Internal server error"} ". </p>
  
  <p><strong>Note:</strong> If I use the same EC2 url with the "Integration Type : HTTP", the "Invoke URL" works. Same is not working with the VPC Link. </p>
  
  <p><strong>Error:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Rsg42.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rsg42.png" alt="enter image description here"></a></p>
  
  <p><strong>Other Points Worth Noting:</strong></p>
  
  <ol>
  <li>In EC2 instance with security policy will allow all TCP ports.</li>
  <li>EC2 instance was launched by using ECS / ECR (Docker Container).</li>
  <li>Enabled the Cloud Watch logs from API Gateway stage, but it produces nothing.</li>
  </ol>
  
  <p>I'm happy to provide additional information, if required.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Based on JNY's (jny) input I have changed the API gateway end point to the NLB and added my EC2 instance as Target in the NLB. Still I'm facing the same issue. Below images will show all the configurations that I have done.</p>
  
  <p><strong>Load Balancer Config:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/HhMCo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HhMCo.png" alt="enter image description here"></a></p>
  
  <p><strong>Load Balancer Target Group settings:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/l4x3Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l4x3Y.png" alt="enter image description here"></a></p>
  
  <p><strong>Target Group Port Settings:</strong></p>
  
  <ol>
  <li>Here I have given 3000 as port to check the instance health as my application (Node) listens on 3000 port.</li>
  <li>Enabled the port numbers 80 and 3000 in the security policy.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/hfcgo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hfcgo.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/pxQz4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pxQz4.png" alt="enter image description here"></a></p>
  
  <p><strong>API Gateway Settings:</strong></p>
  
  <ol>
  <li>Finally I changed the Endpoint the API Gateway to NLB</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/R6MdI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/R6MdI.png" alt="enter image description here"></a></p>
  
  <p><strong>Result of the same:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/4VE1w.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4VE1w.png" alt="enter image description here"></a></p>
  
  <p>Still I'm not sure what is the mistake I'm making here.</p>