Forums

[Errno 111] Connection refused when accessing SendGrid API

I am trying to send an email with the SendGrid api but keeping getting [Errno 111] Connection refused.

I believe I am accessing the api key from my .env file correctly.

My settings from settings.py are:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'apikey' # Name for all the SenGrid accounts
EMAIL_HOST_PASSWORD = os.getenv('SENDGRID_API_KEY')

I have read that free accounts must access only whitelisted api's, and it appears SendGrid's api is whitelisted. Is this not correct? What else am I failing to do here?

Thank you.

You cannot sent SMTP email from a free account. Since sendgrid is on our whitelist, you can use their API to send the email instead.