Connection Error - Unable to connect to the server / port you provided. (IMAP)

Getting “Connection Error - Unable to connect to the server / port you provided. (IMAP)”. while connecting gmail account.
The IMAP, SMTP and POP services are enabled on gmail.
OS: Ubuntu 22.04
MailSpring Version: 1.10.3

Same issue with O365 acc on Ubuntu 22.04

Adding a Gmail account on Arch Linux also appears, Connection Error - Unable to connect to the server / port you provided. (IMAP)