Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emails cannot be sent: "error: [Errno 111] Connection refused" #2604

Closed
thomasjachmann opened this issue Jan 26, 2016 · 4 comments
Closed

Emails cannot be sent: "error: [Errno 111] Connection refused" #2604

thomasjachmann opened this issue Jan 26, 2016 · 4 comments

Comments

@thomasjachmann
Copy link

My Sentry server doesn't send notification emails. It is a newly set up server, so I first thought this is a configuration issue. But on /manage/status/mail/, I can successfully send a test email and when I invite users, these emails also go through. So it seems to be a bug. Even after upgrading to 8.0.4 which tackled that exact problem, Sentry posts error entries into my (single) project. It seems as if Sentry is trying to connect to localhost:25 to send Emails which doesn't correspond my settings of EMAIL_HOST, EMAIL_PORT etc. in sentry.conf.py. Here's a redacted error entry:

{
    "culprit": "socket in create_connection",
    "datetime": "2016-01-26T15:08:36.000000Z",
    "errors": [],
    "extra": {
        "args": [
            "'mail:p:1'",
            1453820902.863131
        ],
        "kwargs": {},
        "sys.argv": [
            "'/usr/local/bin/sentry'",
            "'celery'",
            "'worker'"
        ],
        "task": "<@task: sentry.tasks.digests.deliver_digest of sentry:0x7ff0c019be10>",
        "task_id": "'[removed]'"
    },
    "fingerprint": [
        "{{ default }}"
    ],
    "id": "[removed]",
    "message": "error: [Errno 111] Connection refused",
    "modules": {
        "python": "2.7.11",
        "sentry": "8.0.4"
    },
    "platform": "python",
    "project": 1,
    "release": null,
    "sentry.interfaces.Exception": {
        "exc_omitted": null,
        "values": [
            {
                "module": "socket",
                "stacktrace": {
                    "frames": [
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/celery/app/trace.py",
                            "context_line": "                    R = retval = fun(*args, **kwargs)",
                            "filename": "celery/app/trace.py",
                            "function": "trace_task",
                            "in_app": false,
                            "lineno": 240,
                            "module": "celery.app.trace",
                            "post_context": [
                                "                    state = SUCCESS",
                                "                except Reject as exc:",
                                "                    I, R = Info(REJECTED, exc), ExceptionInfo(internal=True)",
                                "                    state, retval = I.state, I.retval",
                                "                except Ignore as exc:"
                            ],
                            "pre_context": [
                                "                        request=task_request,",
                                "                    )",
                                "",
                                "                # -*- TRACE -*-",
                                "                try:"
                            ],
                            "vars": {
                                "I": null,
                                "IGNORE_STATES": [
                                    "'IGNORED'",
                                    "'RETRY'",
                                    "'REJECTED'"
                                ],
                                "Info": "<class 'celery.app.trace.TraceInfo'>",
                                "R": null,
                                "app": "<Celery sentry:0x7ff0c019be10>",
                                "args": [
                                    "'mail:p:1'",
                                    1453820902.863131
                                ],
                                "backend_cleanup": "<bound method DisabledBackend.process_cleanup of <celery.backends.base.DisabledBackend object at 0x7ff0bcf5c110>>",
                                "eager": false,
                                "exc": "error(111, 'Connection refused')",
                                "fun": "<@task: sentry.tasks.digests.deliver_digest of sentry:0x7ff0c019be10>",
                                "hostname": "'[removed]'",
                                "kwargs": {},
                                "loader_cleanup": "<bound method AppLoader.on_process_cleanup of <celery.loaders.app.AppLoader object at 0x7ff0bff69fd0>>",
                                "loader_task_init": "<bound method AppLoader.on_task_init of <celery.loaders.app.AppLoader object at 0x7ff0bff69fd0>>",
                                "on_chord_part_return": "<bound method DisabledBackend.on_chord_part_return of <celery.backends.base.DisabledBackend object at 0x7ff0bcf5c110>>",
                                "on_error": "<function on_error from celery.app.trace at 0x7ff0bcf718c0>",
                                "pid": 10,
                                "pop_request": "<bound method _LocalStack.pop of <celery.utils.threads._LocalStack object at 0x7ff0bff3c3d0>>",
                                "pop_task": "<bound method _LocalStack.pop of <celery.utils.threads._LocalStack object at 0x7ff0c044ec10>>",
                                "postrun_receivers": [
                                    [
                                        [
                                            [
                                                "\"'140672043067216'\"",
                                                "\"'140672042996632'\""
                                            ],
                                            140672168983328
                                        ],
                                        "BoundMethodWeakref( <sentry.options.store.OptionsStore object at 0x7ff0c3282750>.maybe_clean_local_cache )"
                                    ],
                                    [
                                        [
                                            [
                                                "\"'140671986930256'\"",
                                                "\"'140671986876000'\""
                                            ],
                                            140672168983328
                                        ],
                                        "BoundMethodWeakref( <sentry.models.groupmeta.GroupMetaManager object at 0x7ff0bfcf9250>.clear_local_cache )"
                                    ],
                                    [
                                        [
                                            [
                                                "\"'140671986227216'\"",
                                                "\"'140671986230288'\""
                                            ],
                                            140672168983328
                                        ],
                                        "BoundMethodWeakref( <sentry.models.organizationoption.OrganizationOptionM..."
                                    ]
                                ],
                                "publish_result": true,
                                "push_request": "<bound method _LocalStack.push of <celery.utils.threads._LocalStack object at 0x7ff0bff3c3d0>>",
                                "push_task": "<bound method _LocalStack.push of <celery.utils.threads._LocalStack object at 0x7ff0c044ec10>>",
                                "request": {
                                    "'args'": [
                                        "'mail:p:1'",
                                        1453820902.863131
                                    ],
                                    "'callbacks'": null,
                                    "'chord'": null,
                                    "'errbacks'": null,
                                    "'eta'": null,
                                    "'expires'": null,
                                    "'id'": "'[removed]'",
                                    "'kwargs'": {},
                                    "'retries'": 0,
                                    "'task'": "'sentry.tasks.digests.deliver_digest'",
                                    "'taskset'": null,
                                    "'timelimit'": [
                                        null,
                                        null
                                    ],
                                    "'utc'": true,
                                    "u'correlation_id'": "'[removed]'",
                                    "u'delivery_info'": {
                                        "u'exchange'": "'default'",
                                        "u'priority'": 0,
                                        "u'redelivered'": null,
                                        "u'routing_key'": "'digests.delivery'"
                                    },
                                    "u'group'": null,
                                    "u'headers'": {},
                                    "u'hostname'": "'[removed]'",
                                    "u'is_eager'": false,
                                    "u'reply_to'": "'[removed]'"
                                },
                                "retval": null,
                                "signature": "<function maybe_signature from celery.canvas at 0x7ff0c01eac08>",
                                "state": null,
                                "store_result": "<bound method DisabledBackend.store_result of <celery.backends.base.DisabledBackend object at 0x7ff0bcf5c110>>",
                                "success_receivers": [
                                    [
                                        [
                                            "'sentry.stats.tasks.finished'",
                                            140672168983328
                                        ],
                                        "<function handler from sentry.receivers.stats at 0x7ff0c376c758>"
                                    ]
                                ],
                                "task": "<@task: sentry.tasks.digests.deliver_digest of sentry:0x7ff0c019be10>",
                                "task_after_return": null,
                                "task_on_success": null,
                                "task_request": "<Context: {'chord': None, 'retries': 0, 'args': ('mail:p:1', 1453820902.863131), u'is_eager': False, u'correlation_id': '[removed]', 'errbacks': None, 'taskset': None, '_children': [<AsyncResult: [removed]>], 'id': '[removed]', u'headers': {}, 'called_directly': False, 'utc': True, 'task': 'sentry.tasks.digests.deliver_digest', u'group': None, 'callbacks': None, u'delivery_info': {u'priority': 0, u'redelivered': None, u'rout...",
                                "track_started": false,
                                "uuid": "'[removed]'"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/celery/app/trace.py",
                            "context_line": "                return self.run(*args, **kwargs)",
                            "filename": "celery/app/trace.py",
                            "function": "__protected_call__",
                            "in_app": false,
                            "lineno": 438,
                            "module": "celery.app.trace",
                            "post_context": [
                                "            return orig(self, *args, **kwargs)",
                                "        BaseTask.__call__ = __protected_call__",
                                "        BaseTask._stackprotected = True"
                            ],
                            "pre_context": [
                                "            stack = self.request_stack",
                                "            req = stack.top",
                                "            if req and not req._protected and \\",
                                "                    len(stack) == 1 and not req.called_directly:",
                                "                req._protected = 1"
                            ],
                            "vars": {
                                "args": [
                                    "'mail:p:1'",
                                    1453820902.863131
                                ],
                                "kwargs": {},
                                "orig": "<unbound method Task.__call__>",
                                "req": "<Context: {'chord': None, 'retries': 0, 'args': ('mail:p:1', 1453820902.863131), u'is_eager': False, u'correlation_id': '[removed]', 'errbacks': None, 'taskset': None, '_children': [<AsyncResult: [removed]>], 'id': '[removed]', u'headers': {}, 'called_directly': False, 'utc': True, 'task': 'sentry.tasks.digests.deliver_digest', u'group': None, 'callbacks': None, u'delivery_info': {u'priority': 0, u'redelivered': None, u'rout...",
                                "self": "<@task: sentry.tasks.digests.deliver_digest of sentry:0x7ff0c019be10>",
                                "stack": "<celery.utils.threads._LocalStack object at 0x7ff0bff3c3d0>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/tasks/base.py",
                            "context_line": "                    result = func(*args, **kwargs)",
                            "filename": "sentry/tasks/base.py",
                            "function": "_wrapped",
                            "in_app": true,
                            "lineno": 54,
                            "module": "sentry.tasks.base",
                            "post_context": [
                                "                finally:",
                                "                    Raven.context.clear()",
                                "            return result",
                                "        return app.task(name=name, **kwargs)(_wrapped)",
                                "    return wrapped"
                            ],
                            "pre_context": [
                                "                'transaction_id': transaction_id,",
                                "            })",
                                "            with metrics.timer(key, instance=instance), \\",
                                "                    track_memory_usage('jobs.memory_change', instance=instance):",
                                "                try:"
                            ],
                            "vars": {
                                "args": [
                                    "'mail:p:1'",
                                    1453820902.863131
                                ],
                                "func": "<function deliver_digest from sentry.tasks.digests at 0x7ff0c3761b90>",
                                "instance": "'sentry.tasks.digests.deliver_digest'",
                                "key": "'jobs.duration'",
                                "kwargs": {},
                                "name": "'sentry.tasks.digests.deliver_digest'",
                                "stat_suffix": null,
                                "transaction_id": null
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/tasks/digests.py",
                            "context_line": "        plugin.notify_digest(project, digest)",
                            "filename": "sentry/tasks/digests.py",
                            "function": "deliver_digest",
                            "in_app": true,
                            "lineno": 71,
                            "module": "sentry.tasks.digests",
                            "pre_context": [
                                "    except InvalidState as error:",
                                "        logger.info('Skipped digest delivery: %s', error, exc_info=True)",
                                "        return",
                                "",
                                "    if digest:"
                            ],
                            "vars": {
                                "digest": {
                                    "<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u'Send a notification for regressions'>": {
                                        "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>": [
                                            [
                                                "'\\'\"\\\\\\'[removed]\\\\\\'\"\\''",
                                                "'\\'[\\\\\\'<Event at 0x7ff0bc8ee690: id=545L, project_id=1L, group_id=2L>\\\\\\', [u\"u\\\\\\'<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u\\\\\\'Send a notification for regressions\\\\\\'>\\\\\\'\"]]\\''",
                                                "\"'1453820573.0'\""
                                            ]
                                        ]
                                    }
                                },
                                "digests": "<sentry.digests.backends.redis.RedisBackend object at 0x7ff0bfe36810>",
                                "key": "'mail:p:1'",
                                "minimum_delay": null,
                                "plugin": "<sentry.plugins.sentry_mail.models.MailPlugin object at 0x7ff0bcf21598>",
                                "project": "<Project at 0x7ff0bc8eeed0: id=1L, team_id=1L, slug=u'[removed]'>",
                                "records": "<itertools.islice object at 0x7ff0bc8abfc8>",
                                "schedule_timestamp": 1453820902.863131
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/plugins/sentry_mail/models.py",
                            "context_line": "            return self.notify(notification)",
                            "filename": "sentry/plugins/sentry_mail/models.py",
                            "function": "notify_digest",
                            "in_app": true,
                            "lineno": 210,
                            "module": "sentry.plugins.sentry_mail.models",
                            "post_context": [
                                "",
                                "        context = {",
                                "            'start': start,",
                                "            'end': end,",
                                "            'project': project,"
                            ],
                            "pre_context": [
                                "                    groups.get(group, []) for groups in digest.itervalues(),",
                                "                ),",
                                "                key=lambda record: record.timestamp,",
                                "            )",
                                "            notification = Notification(record.value.event, rules=record.value.rules)"
                            ],
                            "vars": {
                                "counts": {
                                    "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>": 1
                                },
                                "digest": {
                                    "<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u'Send a notification for regressions'>": {
                                        "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>": [
                                            [
                                                "'\\'\"\\\\\\'[removed]\\\\\\'\"\\''",
                                                "'\\'[\\\\\\'<Event at 0x7ff0bc8ee690: id=545L, project_id=1L, group_id=2L>\\\\\\', [u\"u\\\\\\'<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u\\\\\\'Send a notification for regressions\\\\\\'>\\\\\\'\"]]\\''",
                                                "\"'1453820573.0'\""
                                            ]
                                        ]
                                    }
                                },
                                "end": "datetime.datetime(2016, 1, 26, 15, 2, 53, tzinfo=<UTC>)",
                                "group": "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>",
                                "notification": "<sentry.plugins.base.structs.Notification object at 0x7ff0bc6cf0e0>",
                                "project": "<Project at 0x7ff0bc8eeed0: id=1L, team_id=1L, slug=u'[removed]'>",
                                "record": [
                                    "'[removed]'",
                                    [
                                        "<Event at 0x7ff0bc8ee690: id=545L, project_id=1L, group_id=2L>",
                                        [
                                            "<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u'Send a notification for regressions'>"
                                        ]
                                    ],
                                    1453820573.0
                                ],
                                "self": "<sentry.plugins.sentry_mail.models.MailPlugin object at 0x7ff0bcf21598>",
                                "start": "datetime.datetime(2016, 1, 26, 15, 2, 53, tzinfo=<UTC>)"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/plugins/sentry_mail/models.py",
                            "context_line": "            context=context,",
                            "filename": "sentry/plugins/sentry_mail/models.py",
                            "function": "notify",
                            "in_app": true,
                            "lineno": 191,
                            "module": "sentry.plugins.sentry_mail.models",
                            "post_context": [
                                "        )",
                                "",
                                "    def notify_digest(self, project, digest):",
                                "        start, end, counts = get_digest_metadata(digest)",
                                ""
                            ],
                            "pre_context": [
                                "            template=template,",
                                "            html_template=html_template,",
                                "            project=project,",
                                "            group=group,",
                                "            headers=headers,"
                            ],
                            "vars": {
                                "context": {
                                    "'enhanced_privacy'": "'<Bit: number=1, is_set=True>'",
                                    "'event'": "<Event at 0x7ff0bc8ee690: id=545L, project_id=1L, group_id=2L>",
                                    "'group'": "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>",
                                    "'link'": "'[removed]'",
                                    "'project_label'": "u'[removed]'",
                                    "'rules'": [
                                        [
                                            "u'Send a notification for regressions'",
                                            "'[removed]'"
                                        ]
                                    ]
                                },
                                "enhanced_privacy": "'<Bit: number=1, is_set=True>'",
                                "event": "<Event at 0x7ff0bc8ee690: id=545L, project_id=1L, group_id=2L>",
                                "group": "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>",
                                "headers": {
                                    "'X-Sentry-Logger'": "u''",
                                    "'X-Sentry-Logger-Level'": "u'error'",
                                    "'X-Sentry-Project'": "u'[removed]'",
                                    "'X-Sentry-Reply-To'": "'[removed]@localhost'",
                                    "'X-Sentry-Team'": "u'[removed]'"
                                },
                                "html_template": "'sentry/emails/error.html'",
                                "link": "'[removed]'",
                                "notification": "<sentry.plugins.base.structs.Notification object at 0x7ff0bc6cf0e0>",
                                "org": "<Organization at 0x7ff0bc8ae1d0: id=1L, owner_id=None, name=u'[removed]', slug=u'[removed]'>",
                                "project": "<Project at 0x7ff0bc8eeed0: id=1L, team_id=1L, slug=u'[removed]'>",
                                "rule": "<Rule at 0x7ff0bc8ae5d0: id=2L, project_id=1L, label=u'Send a notification for regressions'>",
                                "rule_link": "'[removed]'",
                                "rules": [
                                    [
                                        "u'Send a notification for regressions'",
                                        "'[removed]'"
                                    ]
                                ],
                                "self": "<sentry.plugins.sentry_mail.models.MailPlugin object at 0x7ff0bcf21598>",
                                "subject": "'[[removed]] ERROR: error: [Errno 111] Connection refused'",
                                "template": "'sentry/emails/error.txt'"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/plugins/sentry_mail/models.py",
                            "context_line": "            return message.send()",
                            "filename": "sentry/plugins/sentry_mail/models.py",
                            "function": "_send_mail",
                            "in_app": true,
                            "lineno": 77,
                            "module": "sentry.plugins.sentry_mail.models",
                            "post_context": [
                                "",
                                "    def send_test_mail(self, project=None):",
                                "        self._send_mail(",
                                "            subject='Test Email',",
                                "            body='This email was requested as a test of Sentry\\'s outgoing email',"
                            ],
                            "pre_context": [
                                "        return msg",
                                "",
                                "    def _send_mail(self, *args, **kwargs):",
                                "        message = self._build_message(*args, **kwargs)",
                                "        if message is not None:"
                            ],
                            "vars": {
                                "args": [],
                                "kwargs": {
                                    "'context'": {
                                        "'enhanced_privacy'": "'<Bit: number=1, is_set=True>'",
                                        "'event'": "<Event at 0x7ff0bc8ee690: id=545L, pr...",
                                        "'group'": "<Group at 0x7ff0bc8ae6d0: id=2L, project_id=1L>",
                                        "'link'": "'[removed]'",
                                        "'project_label'": "u'[removed]'",
                                        "'rules'": [
                                            [
                                                "'\\'u\"u\\\\\\'Send a notification for regressions\\\\\\'\"\\''",
                                                "'\\'\"\\\\\\'[removed]/\\\\\\'\"\\''"
                                            ]
                                        ]
                                    },
                                    "'project'": "<Project at 0x7ff0bc8eeed0: id=1L, team_id=1L, slug=u'[removed]'>",
                                    "'subject'": "'[[removed]] ERROR: error: [Errno 111] Connection refused'"
                                },
                                "message": "<sentry.utils.email.MessageBuilder object at 0x7ff0bc8e8090>",
                                "self": "<sentry.plugins.sentry_mail.models.MailPlugin object at 0x7ff0bcf21598>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/utils/email.py",
                            "context_line": "        self.send_all(messages, fail_silently=fail_silently)",
                            "filename": "sentry/utils/email.py",
                            "function": "send",
                            "in_app": true,
                            "lineno": 254,
                            "module": "sentry.utils.email",
                            "post_context": [
                                "",
                                "    def send_all(self, messages, fail_silently=False):",
                                "        connection = get_connection(fail_silently=fail_silently)",
                                "        metrics.incr('email.sent', len(messages))",
                                "        return connection.send_messages(messages)"
                            ],
                            "pre_context": [
                                "            logger.debug('Did not build any messages, no users to send to.')",
                                "        return results",
                                "",
                                "    def send(self, to=None, bcc=None, fail_silently=False):",
                                "        messages = self.get_built_messages(to, bcc=bcc)"
                            ],
                            "vars": {
                                "bcc": null,
                                "fail_silently": false,
                                "messages": [
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc3dd690>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aef90>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aee10>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8e8cd0>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0710>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0910>"
                                ],
                                "self": "<sentry.utils.email.MessageBuilder object at 0x7ff0bc8e8090>",
                                "to": null
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/sentry/utils/email.py",
                            "context_line": "        return connection.send_messages(messages)",
                            "filename": "sentry/utils/email.py",
                            "function": "send_all",
                            "in_app": true,
                            "lineno": 259,
                            "module": "sentry.utils.email",
                            "post_context": [
                                "",
                                "    def send_async(self, to=None, bcc=None):",
                                "        from sentry.tasks.email import send_email",
                                "        messages = self.get_built_messages(to, bcc=bcc)",
                                "        for message in messages:"
                            ],
                            "pre_context": [
                                "        self.send_all(messages, fail_silently=fail_silently)",
                                "",
                                "    def send_all(self, messages, fail_silently=False):",
                                "        connection = get_connection(fail_silently=fail_silently)",
                                "        metrics.incr('email.sent', len(messages))"
                            ],
                            "vars": {
                                "connection": "<django.core.mail.backends.smtp.EmailBackend object at 0x7ff0bc7c08d0>",
                                "fail_silently": false,
                                "messages": [
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc3dd690>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aef90>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aee10>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8e8cd0>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0710>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0910>"
                                ],
                                "self": "<sentry.utils.email.MessageBuilder object at 0x7ff0bc8e8090>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py",
                            "context_line": "            new_conn_created = self.open()",
                            "filename": "django/core/mail/backends/smtp.py",
                            "function": "send_messages",
                            "in_app": false,
                            "lineno": 87,
                            "module": "django.core.mail.backends.smtp",
                            "post_context": [
                                "            if not self.connection:",
                                "                # We failed silently on open().",
                                "                # Trying to send would be pointless.",
                                "                return",
                                "            num_sent = 0"
                            ],
                            "pre_context": [
                                "        messages sent.",
                                "        \"\"\"",
                                "        if not email_messages:",
                                "            return",
                                "        with self._lock:"
                            ],
                            "vars": {
                                "email_messages": [
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc3dd690>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aef90>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8aee10>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0bc8e8cd0>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0710>",
                                    "<django.core.mail.message.EmailMultiAlternatives object at 0x7ff0c06d0910>"
                                ],
                                "self": "<django.core.mail.backends.smtp.EmailBackend object at 0x7ff0bc7c08d0>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py",
                            "context_line": "                                           local_hostname=DNS_NAME.get_fqdn())",
                            "filename": "django/core/mail/backends/smtp.py",
                            "function": "open",
                            "in_app": false,
                            "lineno": 48,
                            "module": "django.core.mail.backends.smtp",
                            "post_context": [
                                "            if self.use_tls:",
                                "                self.connection.ehlo()",
                                "                self.connection.starttls()",
                                "                self.connection.ehlo()",
                                "            if self.username and self.password:"
                            ],
                            "pre_context": [
                                "            return False",
                                "        try:",
                                "            # If local_hostname is not specified, socket.getfqdn() gets used.",
                                "            # For performance, we use the cached FQDN for local_hostname.",
                                "            self.connection = smtplib.SMTP(self.host, self.port,"
                            ],
                            "vars": {
                                "self": "<django.core.mail.backends.smtp.EmailBackend object at 0x7ff0bc7c08d0>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/smtplib.py",
                            "context_line": "            (code, msg) = self.connect(host, port)",
                            "filename": "python2.7/smtplib.py",
                            "function": "__init__",
                            "in_app": false,
                            "lineno": 256,
                            "module": "smtplib",
                            "post_context": [
                                "            if code != 220:",
                                "                raise SMTPConnectError(code, msg)",
                                "        if local_hostname is not None:",
                                "            self.local_hostname = local_hostname",
                                "        else:"
                            ],
                            "pre_context": [
                                "",
                                "        \"\"\"",
                                "        self.timeout = timeout",
                                "        self.esmtp_features = {}",
                                "        if host:"
                            ],
                            "vars": {
                                "host": "'localhost'",
                                "local_hostname": "'[removed]'",
                                "port": 25,
                                "self": "<smtplib.SMTP instance at 0x7ff0bc0f5bd8>",
                                "timeout": "<object object at 0x7ff0cac780d0>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/smtplib.py",
                            "context_line": "        self.sock = self._get_socket(host, port, self.timeout)",
                            "filename": "python2.7/smtplib.py",
                            "function": "connect",
                            "in_app": false,
                            "lineno": 316,
                            "module": "smtplib",
                            "post_context": [
                                "        (code, msg) = self.getreply()",
                                "        if self.debuglevel > 0:",
                                "            print>>stderr, \"connect:\", msg",
                                "        return (code, msg)",
                                ""
                            ],
                            "pre_context": [
                                "                    raise socket.error, \"nonnumeric port\"",
                                "        if not port:",
                                "            port = self.default_port",
                                "        if self.debuglevel > 0:",
                                "            print>>stderr, 'connect:', (host, port)"
                            ],
                            "vars": {
                                "host": "'localhost'",
                                "port": 25,
                                "self": "<smtplib.SMTP instance at 0x7ff0bc0f5bd8>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/smtplib.py",
                            "context_line": "        return socket.create_connection((host, port), timeout)",
                            "filename": "python2.7/smtplib.py",
                            "function": "_get_socket",
                            "in_app": false,
                            "lineno": 291,
                            "module": "smtplib",
                            "post_context": [
                                "",
                                "    def connect(self, host='localhost', port=0):",
                                "        \"\"\"Connect to a host on a given port.",
                                "",
                                "        If the hostname ends with a colon (`:') followed by a number, and"
                            ],
                            "pre_context": [
                                "    def _get_socket(self, host, port, timeout):",
                                "        # This makes it simpler for SMTP_SSL to use the SMTP connect code",
                                "        # and just alter the socket connection bit.",
                                "        if self.debuglevel > 0:",
                                "            print>>stderr, 'connect:', (host, port)"
                            ],
                            "vars": {
                                "host": "'localhost'",
                                "port": 25,
                                "self": "<smtplib.SMTP instance at 0x7ff0bc0f5bd8>",
                                "timeout": "<object object at 0x7ff0cac780d0>"
                            }
                        },
                        {
                            "abs_path": "/usr/local/lib/python2.7/socket.py",
                            "context_line": "        raise err",
                            "filename": "python2.7/socket.py",
                            "function": "create_connection",
                            "in_app": false,
                            "lineno": 575,
                            "module": "socket",
                            "post_context": [
                                "    else:",
                                "        raise error(\"getaddrinfo returns an empty list\")"
                            ],
                            "pre_context": [
                                "            err = _",
                                "            if sock is not None:",
                                "                sock.close()",
                                "",
                                "    if err is not None:"
                            ],
                            "vars": {
                                "_": "error(111, 'Connection refused')",
                                "address": [
                                    "'localhost'",
                                    25
                                ],
                                "af": 2,
                                "canonname": "''",
                                "err": "error(111, 'Connection refused')",
                                "host": "'localhost'",
                                "port": 25,
                                "proto": 6,
                                "res": [
                                    2,
                                    1,
                                    6,
                                    "''",
                                    [
                                        "'127.0.0.1'",
                                        25
                                    ]
                                ],
                                "sa": [
                                    "'127.0.0.1'",
                                    25
                                ],
                                "sock": "<socket._socketobject object at 0x7ff0bc88f600>",
                                "socktype": 1,
                                "source_address": null,
                                "timeout": "<object object at 0x7ff0cac780d0>"
                            }
                        }
                    ],
                    "frames_omitted": null,
                    "has_system_frames": true
                },
                "type": "error",
                "value": "[Errno 111] Connection refused"
            }
        ]
    },
    "tags": [
        [
            "site",
            "example.com"
        ],
        [
            "level",
            "error"
        ],
        [
            "server_name",
            "[removed]"
        ]
    ],
    "time_spent": null,
    "version": "5"
}
@dcramer
Copy link
Member

dcramer commented Jan 26, 2016

If you're getting a connection refused on outbound emails it means your postfix or other smtp gateway is not configured correctly. If you recently changed the settings its important to note you must restart all Sentry processes to update settings from disk.

@dcramer dcramer closed this as completed Jan 26, 2016
@thomasjachmann
Copy link
Author

@dcramer I'm afraid it's not that easy. As I stated in the description, I don't think it's a configuration issue, since Sentry can send out test emails and invitation emails just fine. Just the notification emails don't get through, so it seems this part of the system doesn't use the correct settings.

@dcramer
Copy link
Member

dcramer commented Jan 26, 2016

@thomasjachmann we do not use multiple email systems. If the web process is allowing emails and the workers are not, it means the workers are not running the same settings as the web processes. A quick sanity check to prove this case is to restart the application processes.

tl;dr there is no magic here :)

@thomasjachmann
Copy link
Author

@dcramer No magic, just different software subsystems diverging over time, that was my assumption. ;) But what diverged were the settings of my web/worker processes, thanks for pointing my thoughts into that direction. I pondered on that problem for quite some time now.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants