Ethernet Client.connect() returns error code -5

I'm not clear what those two bits of code are - the first fragment seems completely different to the second one. The examples connect to a specified IP address. Have you tried doing that? And I suggest you ensure it's a local IP address not something out on the internet, just to eliminate any wide area network issues. I guess that the first code fragment is connecting to a server specified by hostname and that relies on DNS working, which is an extra layer of complexity. Hard-code the IP address for a test as shown in the second example for a better chance of success.