Initial email failure. Job exception: getaddrinfo: Name or service not known

I am trying to install Discourse using the basic Docker script on a new instance of an Ubuntu VM. I’m having an issue with emails not sending.

I’ve followed the steps in the install instructions to the letter. I’ve also done this several times, always with the same results.

I looked in the production.log file (/var/discourse/shared/standalone/log/rails/production.log) and found this:

Sent mail to <myusername>@<mycompany>.com (75.1ms)
Job exception: getaddrinfo: Name or service not known

Here are what I think are the relevant parts of my app.yml file:

DISCOURSE_DEVELOPER_EMAILS: '<myusername>@<mycompany>.com'
DISCOURSE_HOSTNAME: 'discourse-sand.vm.<ourdomain>'

DISCOURSE_SMTP_ADDRESS: <smtpserver>.<ourdomain> # (mandatory)
DISCOURSE_SMTP_PORT: 25                          # (optional)
#DISCOURSE_SMTP_USER_NAME:      # (optional)
#DISCOURSE_SMTP_PASSWORD: pa$$word               # (optional, WARNING the char '#' in pw can caus$
#DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

## If you want to set the 'From' email address for your first registration, uncomment and change:
- exec: rails r "SiteSetting.notification_email='<myusername>@<mycompany>.com'"
## After getting the first signup email, re-comment the line. It only needs to run once.

I’m using an internal SMTP server in our company. I asked IT what to use for authentication and they told me that name and port was the only information I should configure, and leave username and password commented out.

Note that the domain of the VM is vm., so I used that for the DISCOURSE_HOSTNAME account. The only quirk that I thought could be an issue is that this SMTP server is configured to only allow traffic to/from certain internal domains, and I don’t know if vm. is causing a problem. Hence the reason I uncommented the ‘From’ email override at the bottom of the .yml file.

However, looking at the log file, I wonder if it’s having trouble finding the server at all. I’m able to ping the SMTP server from the terminal, but I’m out of my depth in Linux troubleshooting at this point and not sure how or where to dig further. Oh, and I tried to send email through the SMTP server via telnet based on this post, and that succeeded. I’m happy to provide any additional log info but you might need to explain how to get at it - I’m a pretty big noob when it comes to Linux or Ruby but I’m really interested in learning more!

Probably Discourse can’t figure out DNS for your <mycompany>.com.

Set dns in DOCKER_OPTS. You can point to Google DNS server as or ask your IT about internal DNS server (probably you have one)

Then restart docker. You can find the detailed steps by following the link.


@fantasticfears, you’re the best. That seems to have fixed the issue. I had tried disabling dnsmasq earlier in my troubleshooting, based on information I found on Stack Overflow, but the instructions for configuring docker to use our DNS server seems to have done the trick. I was just able to activate my admin account.


1 Like

Just wanted to reiterate - I tried this again with a new VM and everything worked smoothly. In between the step to install Docker and the step to clone Discourse, I followed the steps from this link to configure Docker to look for our DNS servers. This time, after bootstrapping and starting the app, I got the admin email immediately after logging in with my admin account.

1 Like

I also got the same issue. But DOCKER_OPTS didn’t work for me.
I saw that

In the absence of the --dns=IP_ADDRESS…, --dns-search=DOMAIN…, or --dns-opt=OPTION… options, Docker uses the /etc/resolv.conf of the host machine (where the docker daemon runs).

So that was the problem for me. Our dns was not added to the host.