Search code examples
djangoemailsmtpconnectioncpanel

Errno 111 Connection refused Django REST on CPanel


I'm using gmail smtp, and I get this error: [Errno 111] Connection refused

I'm getting this on cpanel shared hosting, but it's working perfectly fine on local.

Here's my Django configuration:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = config("EMAIL_HOST")
EMAIL_PORT = 587
EMAIL_HOST_USER = config("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD")
EMAIL_FROM = config("EMAIL_FROM")
DEFAULT_FROM_EMAIL = 'email@gmail.com'
SERVER_EMAIL = 'email@gmail.com'
EMAIL_BCC = ""
EMAIL_USE_SSL = False

I contacted my WHM and told them to disable smtp restrictions. Their firewall is also not blocking gmail's smtp and the required ports are also open. Please help me.


Solution

  • I fixed this by telling my WHM to add my cPanel username on SMTP_ALLOWUSER as per: SMTP ERROR: Failed to connect to server: Connection refused (111) with Office365