My Ola Hallengren nightly backup job failed but It works fine when I execute the job manually by right clicking
You can try to address the problem by increasing the timeout periods.

Increase the standard settings on your server for remote login timeout (s) and remote query timeout (s).

Or in your connection string you could include "Connect Timeout=120;General Timeout=120;" to increase the time allowed for the connections.