Connection reset by peer error - SendGrid

I am getting a generic “Job exception - Connection reset by peer” error everytime Discourse tries to send an email. I know this error is related to some settings of the current server that it is hosted on because I tried the exact same Discourse Docker install/email settings on another server and it worked right away. Can someone help me understand what should I change on my new server so that emails can be sent? It currently has both ports 443 and 80 opened.

Your server probably has outgoing port 25 blocked.

Try using port 2525 for the outgoing smtp port.

On my config, I am using port 587 and it is opened in my server when I tested using

telnet smtp.sendgrid.net 587