5

I have an ECS cluster with ELB. Last night I saw that a task was stuck in restarting loop. From the service Events log, it said:

"service xxxxx was unable to place a task because no container instance met all of its requirements. The closest matching container-instance xxxxxxxxxxxxxx is already using a port required by your task."

However, I have checked that all such tasks are dead and nothing should be using the port at that time. Updating the service does not help but creating new task definition and then update helps. Terminating the instance and allow ELB to relaunch it helps.

Any idea why the service cannot secure the port for the task?

enter image description here

  • The following information is needed to answer this: What is the port mapping configuration on your ecs task (dynamic vs. static)? How many EC2 hosts do you have, how many tasks are runing on the cluster? – M. Glatki Jun 22 '18 at 9:17
0

I think your problem is the task definition "Network mode" is host or something that works equally, this causes the host port to be already in use when ECS fires deployment.

The way ECS deploys is using your minimum healthy percent, so if you have more than 0%, it needs to start the new task before stopping the old one. In this case, it cant bind the host port on the new task because its in use by the old one.

Try using another Network mode that don't lock host port, like "awsvpc"

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.