I am following Corey Schafer's flask tutorial to setup a basic blog web app. When running the website from my local machine, I am able to send emails through flask-mail for password reset purposes. However, after hosting the website on a linode Ubuntu server, I am receiving a timeout error when I attempt to send an email. The error traceback is:
[2019-12-27 18:15:44,423] ERROR in app: Exception on /reset_password [POST]
Traceback (most recent call last):
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/hansen/FlaskTutorial/flaskblog/users/routes.py", line 84, in reset_request
send_reset_email(user)
File "/home/hansen/FlaskTutorial/flaskblog/users/utils.py", line 29, in send_reset_email
mail.send(msg)
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask_mail.py", line 491, in send
with self.connect() as connection:
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "/home/hansen/FlaskTutorial/venv/lib/python3.7/site-packages/flask_mail.py", line 158, in configure_host
host = smtplib.SMTP(self.mail.server, self.mail.port)
File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py", line 307, in _get_socket
self.source_address)
File "/usr/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
I have tried connecting to the smtp.gmail.com server through telnet on the linux server, and receive the following error:
telnet smtp.gmail.com 587
Trying 2607:f8b0:400d:c03::6d...
Trying 209.85.201.109...
telnet: Unable to connect to remote host: Connection timed out
From other stackoverflow posts, (https://unix.stackexchange.com/questions/151321/cant-access-mail-server-through-smtp), it seems like it is possible that this is a firewall issue. Any help will be much appreciated.