Elasticsearch-7.4.2 getting stuck at having thousands of close_wait connections with logstash-7.4.3

We are running elasticsearch cluster with two nodes and sending logs from 7 different machines using logstash. Elasticsearch keeps working fine for one or two days until we start seeing close_wait connections on master node.These close_wait connections keep piling up until they reach in thousands and elasticsearch becomes unresponsive. All connection are from logstash. They get cleared only either we restart all the logstash instances or we restart our elaticsearch cluster. Has anyone faced the same problem and have any solution.
OS-Ubuntu-20.04.2 lts

According to the official support matrix it does not look like Elasticsearch 7.4 is supported on Ubuntu 20.04 so I would recommend you upgrade to Elasticsearch 7.17 and see if that resolves the issue.