Well…Happened to my Yahoo account on iOS 7.1.2 on my iPhone. Was working till a few hours ago and then, all of a sudden, I could see the email coming in on my iPad, but, the iPhone persisted with the “connection to the server failed”.
Normally, deleting and re-creating the account should generally fix this issue. This is also documented in the Yahoo help and other forums. I did not fancy re-creating the account since that would mean that I would have to download my email all over again.
Surprisingly, the fix for me was quite simple. I switched the password of the account in settings to an invalid one and saved it. Then I changed the password back to the correct one and the account settings were verified and the connectivity issue was resolved.
Hope this helps out some others with a similar issue.