Forums

Flask-Mail using gmail issue. [Errno 111] Connection refused

Hi, I am currently attempting to send a gmail message through my pythonanywhere website. I am using flask_mail and I keep getting an error connecting.

I configured it like so:

app.config.update(
    DEBUG=True,
    #EMAIL SETTINGS
    MAIL_SERVER='smtp.gmail.com',
    MAIL_PORT=465,
    MAIL_USE_SSL=True,
    MAIL_USERNAME = 'blah@gmail.com',
        MAIL_PASSWORD = 'password'
)

The error in the error log shows up like:

2017-12-05 23:23:37,363: Error running WSGI application 2017-12-05 23:23:37,371: ConnectionRefusedError: [Errno 111] Connection refused

...

2017-12-05 23:23:37,390: File "/usr/lib/python3.5/socket.py", line 702, in create_connection 2017-12-05 23:23:37,391: sock.connect(sa)

I have tested it locally and it works. I believe there is a problem with the host. Any suggestions?

have a look at the "google security blocking" section on this page: https://help.pythonanywhere.com/pages/SMTPForFreeUsers -- could that be it?

Have you had any solutions, same probelm with my setup

Did you go to the help link and follow the instructions?

I have got a same problem but not with google. i tried Mailjet, and smtp2go, both are working on localhost but not on pyhtonanywhere. Any solution, Idea, Hello?!!

If you're using those services via SMTP, note that free accounts on PythonAnywhere can only use GMail's SMTP servers -- see the help page linked above.

If you're using an HTTP/HTTPS API that they provide, then it might need to be whitelisted for free accounts. For us to do that, we need a link to their API documentation.,