Push docker image fails but works when executed the second time - Layer already exists - connect: connection refused

The push fails because a layer already exists and there is a connection issue, but it works when executed the second time because the existing layer is detected and no new layer is pushed.

Related articles:

Layer Already Exists
Layer Already Exists is an error message that occurs when a user attempts to create a new layer in a digital image editing program, but the software recognizes an existing layer with the same name or identifier.

Connection Refused
Connection refused is a common error message displayed by computer systems when a connection to another computer or server is not possible. This error message usually appears when a user attempts to connect to a remote computer via a network or the internet, but is unable to establish the connection due to various factors.