# Can’t send emails due to failed internal dns resolution

**URL:** https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592
**Category:** Support
**Created:** [2016年五月3日 08:45 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592 "2016-05-03T08:45:48Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月3日 08:45 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/1 "2016-05-03T08:45:48Z")

</div>

Dear Discourse community,

Im having problems with my instance of Discourse. Although the servers parameters didnt change, and I am able to use them e.g. via simple Python script, the Discourse fails to send emails.

It happened all of a sudden about a month ago after an update. I have rechecked the server parameters, apart from that I’m completely lost.

Here is an error log:

```
/usr/local/lib/ruby/2.0.0/net/smtp.rb:784:in `check_auth_args'
/usr/local/lib/ruby/2.0.0/net/smtp.rb:548:in `do_start'
/usr/local/lib/ruby/2.0.0/net/smtp.rb:520:in `start'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/mail-2.6.4/lib/mail/message.rb:2149:in `do_delivery'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/mail-2.6.4/lib/mail/message.rb:237:in `block in deliver'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.2.6/lib/action_mailer/base.rb:543:in `block in deliver_mail'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.2.6/lib/action_mailer/base.rb:541:in `deliver_mail'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/mail-2.6.4/lib/mail/message.rb:237:in `deliver'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.2.6/lib/action_mailer/message_delivery.rb:85:in `deliver_now'
/var/www/discourse/lib/email/sender.rb:148:in `send'
/var/www/discourse/app/jobs/regular/user_email.rb:41:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年五月3日 09:01 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/2 "2016-05-03T09:01:02Z")

</div>

Can you share your settings? (Makes sure you hide passwords though)

---

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月3日 10:31 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/3 "2016-05-03T10:31:18Z")

</div>

Hey,  
here they are:  
passwd is not needed, its a local server for internal use only:

```yaml
LANG: en_US.UTF-8
DISCOURSE_DEVELOPER_EMAILS: 'megan-community@informatik.uni-tuebingen.de'
DISCOURSE_HOSTNAME: 'megan.informatik.uni-tuebingen.de'
DISCOURSE_SMTP_ADDRESS: 'smtp.informatik.uni-tuebingen.de' # (mandatory)
DISCOURSE_SMTP_PORT: 25 # (optional)
DISCOURSE_SMTP_USER_NAME: 'megan-community@informatik.uni-tuebingen.de' # (optional)
DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)

```

---

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月4日 14:34 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/4 "2016-05-04T14:34:04Z")

</div>

Now when i changed quotation marks, and wanted to rebuild app, it told me to update the Docker. Now Im unable to rebuild an app cause of that:

`fatal: unable to access 'https://github.com/SamSaffron/pups.git/': Could not resolve host: github.com`

Changing DNS and restarting docker like described [here](https://meta.discourse.org/t/could-not-resolve-host-github-com-for-samsaffron-pups-git/32050) didnt solve it.

Getting more and more frustrated…

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年五月4日 14:37 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/5 "2016-05-04T14:37:01Z")

</div>

Can you access `github.com` from your server (using `ping` or better `curl`)? Seems like a DNS issue or a network hiccup.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2016年五月4日 14:44 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/6 "2016-05-04T14:44:00Z")

</div>

Looks like this:

> [@How to restore your site from backup in the terminal?](https://meta.discourse.org/t/how-to-restore-your-site-from-backup-in-the-terminal/42179/6):
>
> Follow the link. There is a detailed step showing how to do that. (1 - 5) For step 3, use DOCKER\_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" as this suggests:

---

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月4日 14:54 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/7 "2016-05-04T14:54:07Z")

</div>

Thanks a lot for your answers!

Unfortunately nothing changed. Ping works,

`DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"`

is like its described. Docker was restarted, error when trying to rebuild remains the same,..

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年五月4日 14:58 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/8 "2016-05-04T14:58:18Z")

</div>

Unable to resolve host is definitely a DNS problem, if that is the error you are seeing.

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [2016年五月4日 15:17 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/9 "2016-05-04T15:17:05Z")

</div>

It looks like two different problems.

Google’s DNS may just help you to access the wild on Internet. It’s for access the web.

For email sending, I am not sure how it works.[quote=“gvalchca, post:3, topic:43592”]  
its a local server for internal use only:  
[/quote]  
You have set a DNS record for your SMTP server. How you prevent it from unauthorized access since you are exposing your username and claim it doesn’t need a password?

---

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月4日 15:28 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/10 "2016-05-04T15:28:44Z")

</div>

its only for the network inside of the institute.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年五月4日 15:35 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/11 "2016-05-04T15:35:30Z")

</div>

Did you try this?

```
cd /var/discourse
git pull
./launcher rebuild app

```

And the only error you are getting is DNS correct? If so then DNS is definitely not working from your server.

The launcher script does not require the smtp setting to have a password.

---

<div class="post-metadata">

### Author: ![gvalchca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gvalchca/32/44015_2.png) [@gvalchca](https://meta.discourse.org/u/gvalchca)
#### Post date: [2016年五月4日 15:39 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/12 "2016-05-04T15:39:17Z")

</div>

Ok, thanks a lot, it all finally worked,  
so:

I’ve changed the DOCKER\_OPTS:  
`DOCKER_OPTS="--ip 127.0.0.1"`

then rebuild the app with the quotations:  
`DISCOURSE_SMTP_AUTHENTICATION: 'none'`  
`DISCOURSE_SMTP_ENABLE_START_TLS: "true"`

Thx a lot!

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [2016年五月4日 15:55 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/13 "2016-05-04T15:55:21Z")

</div>

> [@gvalchca](#):
>
> I’ve changed the DOCKER\_OPTS:DOCKER\_OPTS=“–ip 127.0.0.1”

If that SMTP server should only works in your institution, sure you need your own DNS server.

Beyond that, I guess you reject all kinds of access from outside your LAN.

---

<div class="post-metadata">

### Author: ![Kevin\_McKinney](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_mckinney/32/54497_2.png) [@Kevin\_McKinney](https://meta.discourse.org/u/Kevin_McKinney)
#### Post date: [2016年五月4日 16:02 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/14 "2016-05-04T16:02:38Z")

</div>

> [@gvalchca](#):
>
> I’ve changed the DOCKER\_OPTS:DOCKER\_OPTS=“–ip 127.0.0.1”

The second time I installed Discourse, I was having issues where emails wouldn’t send (same setup as you - internal SMTP at my company). It turned out that I had to [configure Docker to find our DNS server](https://meta.discourse.org/t/initial-email-failure-job-exception-getaddrinfo-name-or-service-not-known/42301/4) because it couldn’t resolve the SMTP server.

I added this to the bottom of my DOCKER\_OPTS:  
`DOCKER_OPTS="--dns 172.X.X.X --dns 172.X.X.X"`

---

<div class="post-metadata">

### Author: ![clay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clay/32/102156_2.png) [@clay](https://meta.discourse.org/u/clay)
#### Post date: [2016年五月4日 16:34 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/15 "2016-05-04T16:34:41Z")

</div>

@gvalchca I had a similar problem with an internal install of Discourse. I noted the fix [in this thread](https://meta.discourse.org/t/images-no-longer-getting-lightboxed-part-3/24485/31). Basically, I had to add the address to the internal DNS server in the host machine’s Docker config file.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2019年一月15日 15:38 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/16 "2019-01-15T15:38:19Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019年一月17日 04:46 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/17 "2019-01-17T04:46:23Z")

</div>

I feel like `discourse_doctor` should be able to “figure this out”. Basically run a container with our base image and run a DNS query or 2.

We do have rake tasks now for testing email, but I think it should be automatic longer term. @pfaffman are we doing anything here?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019年一月17日 05:36 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/18 "2019-01-17T05:36:34Z")

</div>

Discourse-doctor calls the rake task (inside the container). There were some changes to the rake task in the past day or so.

I submitted something last summer (?) that added to discourse-setup recommending to run discourse-doctor, they I think was never merged.

It might make sense to have discourse-setup run the rake task after the container gets cranked up. (I now run it routinely after I do an install, though I have to wait for the client to do the dns config before I do.)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2022年一月7日 11:17 UTC](https://meta.discourse.org/t/can-t-send-emails-due-to-failed-internal-dns-resolution/43592/19 "2022-01-07T11:17:21Z")

</div>


