Report this

What is the reason for this report?

I am unable to send email from django app (502 Bad Gateway error)

Posted on May 19, 2020

Hi there, Its been days and I am stuck. Whenever I try to send email, I get “502 Bad Gateway” error. Configuration:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'golf.mywebsitebox.com' 
EMAIL_HOST_USER = '' 
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 465
EMAIL_USE_TLS = True

I am using Ubunto OS with Nginx and Gunicorn. I have opened ticket twice with this issue but no one is responding. Hope someone here responds.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @mahawaqar9875,

There are a few things that you need to consider:

  • If you are using a firewall on your Droplet like UFW, make sure to allow the outgoing TCP traffic for port 465

  • If you are using a Cloud Firewall, make sure to allow the outgoing TCP traffic for port 465 as well

  • Once you have opened port 465, test this is actually the case by running the following command from your Droplet:

  1. telnet portquiz.net 465
  • If you have port 465 open already try running telnet from your Droplet to your mail server:
  1. telnet golf.mywebsitebox.com 465
  • Make sure that your Droplet’s IP address is not blocked by the firewall on your mail server

Let me know how it goes! Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.