Namshi gmail-smtp-in.l.google.com Cannot assign requested address

Hello, I have trouble with SMTP.

in the smtp log:

namshi gmail-smtp-in.l.google.com ... Cannot assign requested address

Why could this be?
1. I read the discussion here:
here

The local project is set up with a protonmail address
I have not configured SSL certificates for the domain.
I used the command line
tutor config save --set EMAIL_HOST_USER=
etc. to configure and it did save these settings in .local/share/tutor/config.yml :

CONTACT_EMAIL: ptm_user@protonmail.com
EMAIL_HOST: smtp.gmail.com
EMAIL_HOST_PASSWORD: secret
EMAIL_HOST_USER: gmail_user
EMAIL_PORT: 587
EMAIL_USE_TLS: true

~/.local/share/tutor/env/apps/openedx/config$ nano lms.env.json

"EMAIL_HOST": "smtp",
"EMAIL_PORT": 25,
"EMAIL_USE_TLS": false,
"EMAIL_HOST_USER": "",
"EMAIL_HOST_PASSWORD": ""

My guess is that setting “allow less secure apps” in gmail is sufficient and that either SSL certificates are required on the client or there is a protonmail/gmail conflict. Who knows? How to further analyse?

2. I read

this and it is true that I also cannot traceroute via port 25. I am also running tutor on EC2.

sudo traceroute -n -T -p 25 gmail-smtp-in.l.google.com shows only ***
sudo traceroute -n -T -p 80 gmail-smtp-in.l.google.com does seem to resolve:
sudo traceroute -n -T -p 80 gmail-smtp-in.l.google.com
traceroute to gmail-smtp-in.l.google.com (74.125.24.26), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 100.65.10.161 0.395 ms 100.65.8.161 0.389 ms 100.65.10.129 0.285 ms
7 52.95.38.155 1.795 ms 52.95.38.18 1.024 ms 52.95.38.155 1.075 ms
8 52.95.36.62 1.792 ms 52.95.36.142 1.910 ms 52.95.36.94 1.984 ms
9 54.240.203.232 1.701 ms 54.240.203.222 1.681 ms 54.240.203.232 1.890 ms
10 99.82.183.99 1.164 ms 1.192 ms 1.157 ms
11 72.14.236.69 1.162 ms 108.170.247.33 2.616 ms 2.614 ms
12 108.170.247.90 1.295 ms 1.289 ms 108.170.247.34 1.668 ms
13 172.253.79.100 93.441 ms 142.250.63.0 93.432 ms 172.253.79.104 93.414 ms
14 209.85.245.232 93.416 ms 108.170.230.73 104.172 ms 209.85.243.180 93.164 ms
15 172.253.68.247 93.375 ms 66.249.94.59 92.745 ms 172.253.68.251 94.307 ms
16 * * *

3. I also have about 100 times:

[django.security.DisallowedHost] [user None] exception.py:77 - Invalid HTTP_HOST header: xx.AWS-IP.xx.xx:80'. You may need to add 'xx.AWS-IP.xx.xx' to ALLOWED_HOSTS.

and the same for 0.0.0.0
and the same for You may need to add ‘smtp.243.38.a6gvhbavpxxcxau.com’ to ALLOWED_HOSTS.

smtp.243.38.a6gvhbavpxxcxau.com leads to match-room.jp (I’m in Japan but I don’t know what this is).

Later in the log, ^[[34;1mnginx_1 |^[[0m 209.17.96.82 - - [25/Jul/2020:16:54:22 +0000] http://smtp.243.38.a6gvhbavpxxcxau.com "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (compatible; Nimbostratus-Bot/v1.3.2; http://cloudsystemnetworks.com)" "-"
Note that 209.17.96.82 is Cogent, which I don’t recognize and

I have no limits on the outgoing traffic from the EC2 instance. This may be from the CMS container, but how can I change ALLOWED_HOSTS from the tutor command line?

4. I see that

^[[32msmtp_1 |^[[0m 674 Connecting to gmail-smtp-in.l.google.com [2404:6800:4003:c04::1b]:25 ... failed: Cannot assign requested address ^[[32msmtp_1 |^[[0m 674 LOG: MAIN ^[[32msmtp_1 |^[[0m 674 H=gmail-smtp-in.l.google.com [2404:xx:xx:xx::xx] Cannot assign requested address ^[[32msmtp_1 |^[[0m 674 Connecting to gmail-smtp-in.l.google.com [xx.xx.xx.xx]:25 ... failed: Connection timed out (timeout=5m) here it seems that port 25 is used. This seems correct, that the gmail server can be connected to over this port, but I don’t see 587 being used locally.

Why did you configure tutor with EMAIL_* settings? You should use SMTP_* variables, as described here: https://docs.tutor.overhang.io/configuration.html#smtp
If you want to use the Google servers for sending email you should also set ACTIVATE_SMTP=false.

Thanks, I just found that out myself from another question on this board. I followed a tutorial for openEdX.

ACTIVATE_SMTP is probably false by default? It seems to work without setting this explicitly.

The problem could be made clearer I think. The logs are misleading. It took me too long to figure it out. Maybe I’ll file an issue.

No, it is true by default. Configuration and customisation — Tutor documentation

Yes, it works, but the namshi SMTP server runs needlessly when you set a different SMTP_HOST with ACTIVATE_SMTP=true.

You should really read the docs instead of blindly following 3rd-party tutorials. Granted, sometimes the docs are wrong, but they will always be the most authoritative and up-to-date source of information.

OK, thanks. I found this confusing in the docs too, there it says:

Note that the SMTP server shipped with Tutor by default does not implement TLS.

But gmail is an alternative server/when using gmail, Tutor is client.
The default settings in the docs are not sufficient when using gmail, so you automatically start web searching. Then you see that you need to enable /lesssecureapps in your gmail account and that the port is 587. Then I missed the EMAIL_/SMTP_ difference. I think EdX uses EMAIL_ for SMTP settings by the way.

And I tend to rely on logs too. I’m not sure all of the smtp exim mainlog is in the docker log from --follow. But in the exim log it says, cannot assign requested address. This is from exim on the namshi image, the bash script there could check and print more or the tutor scripts could in my opinion because this message sounds more like a DNS issue.

I needed to look around the docker containers anyway and set up https in the process. Does the Tutor documentation cover all of EdX?

After running tutor local quickstart, should the server be able to send verification emails? Currently, I get a connection timeout error while the smtp server tries to connect to my personal email. I am not sure what I have missed.

smtp_1           |   274 LOG: smtp_connection MAIN
smtp_1           |   274   SMTP connection from tutor_local_lms-worker_1.tutor_local_default (972750d35c07) [172.18.0.10] closed by QUIT
smtp_1           |   275 Exim version 4.92 uid=101 gid=101 pid=275 D=80001
smtp_1           | Berkeley DB: Berkeley DB 5.3.28: (September  9, 2013)
smtp_1           | Support for: crypteq iconv() IPv6 GnuTLS move_frozen_messages DANE DKIM DNSSEC Event OCSP PRDR SOCKS TCP_Fast_Open
smtp_1           | Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmjz dbmnz dnsdb dsearch nis nis0 passwd
smtp_1           | Authenticators: cram_md5 plaintext
smtp_1           | Routers: accept dnslookup ipliteral manualroute queryprogram redirect
smtp_1           | Transports: appendfile/maildir/mailstore autoreply lmtp pipe smtp
smtp_1           | Fixed never_users: 0
smtp_1           | Configure owner: 0:0
smtp_1           | Size of off_t: 8
smtp_1           |   275 delivering 1lv0Ag-00004Q-23
smtp_1           |   275 R: dnslookup for b***d@m***d.com
smtp_1           |   276 T: remote_smtp for b***d@m***d.com
smtp_1           |   276 Connecting to gmr-smtp-in.l.google.com [2a00:1450:400c:c1b::e]:25 ... failed: Cannot assign requested address
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=gmr-smtp-in.l.google.com [2a00:1450:400c:c1b::e] Cannot assign requested address
smtp_1           |   276 Connecting to gmr-smtp-in.l.google.com [142.251.5.14]:25 ... failed: Connection timed out (timeout=5m)
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=gmr-smtp-in.l.google.com [142.251.5.14] Connection timed out
smtp_1           |   276 Connecting to alt1.gmr-smtp-in.l.google.com [2a00:1450:4025:c03::e]:25 ... failed: Cannot assign requested address
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=alt1.gmr-smtp-in.l.google.com [2a00:1450:4025:c03::e] Cannot assign requested address
smtp_1           |   276 Connecting to alt1.gmr-smtp-in.l.google.com [142.251.9.14]:25 ... failed: Connection timed out (timeout=5m)
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=alt1.gmr-smtp-in.l.google.com [142.251.9.14] Connection timed out
smtp_1           |   276 Connecting to alt2.gmr-smtp-in.l.google.com [2a00:1450:4010:c1c::e]:25 ... failed: Cannot assign requested address
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=alt2.gmr-smtp-in.l.google.com [2a00:1450:4010:c1c::e] Cannot assign requested address
smtp_1           |   276 Connecting to alt3.gmr-smtp-in.l.google.com [2404:6800:4003:c00::e]:25 ... failed: Cannot assign requested address
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=alt3.gmr-smtp-in.l.google.com [2404:6800:4003:c00::e] Cannot assign requested address
smtp_1           |   276 Connecting to alt4.gmr-smtp-in.l.google.com [2404:6800:4008:c13::e]:25 ... failed: Cannot assign requested address
smtp_1           |   276 LOG: MAIN
smtp_1           |   276   H=alt4.gmr-smtp-in.l.google.com [2404:6800:4008:c13::e] Cannot assign requested address
smtp_1           |   275 LOG: MAIN