Question

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

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.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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