Connecting to Remote Server Failed: Unable to connect to IP:PORT: Bad file descriptor

When we try to transfer domains using WHM transfer we are getting the following error:

Connecting to Remote Server Failed: Unable to connect to IP:PORT: Bad file descriptor

To resolve this error:

Disable firewalls on both servers especially on destination server and try to connect again.