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?
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!