Bitwarden_rs: SMTP not connecting: SMTP IO error: Resource temporarily unavailable (os error 11)

Created on 28 Oct 2020  路  16Comments  路  Source: dani-garcia/bitwarden_rs

Hello,

For some reason sending email with SMTP is not working with bitwarden_rs latest image. I get the following error in my log file: SMTP IO error: Resource temporarily unavailable (os error 11). My understanding is this error is caused by the host and not from the remote SMTP server.
No luck on troubleshooting this issue so far...

Environment

  • Bitwarden_rs version: 1.17.0
  • Install method: Docker (latest)
  • Clients used: web ui

Extract of my docker compose file:

version: "3"

services:
  bitwarden_rs:
    hostname: 'XXX-BITWARDEN-CONTAINER'
    container_name: bitwarden_xxx
    image: bitwardenrs/server:latest
    ports:
      - "127.0.0.1:8004:80/tcp"
    environment:
      DOMAIN: "https://xxx"
      SIGNUPS_ALLOWED: "false"
      DATABASE_URL: "mysql://bitwarden:xxx@xxx/xxx"
      ENABLE_DB_WAL: "false"
      SMTP_HOST: "xxx"
      SMTP_FROM: "xxx"
      SMTP_PORT: 465
      SMTP_SSL: "true"
      SMTP_USERNAME: "xxx"
      SMTP_PASSWORD: "xxx"
      #LOG_LEVEL: "warn"
    volumes:
      - '/etc/hosts:/etc/hosts'
      - './bw_data/:/data/'
    restart: unless-stopped

Relevant logs

[2020-10-28 13:56:49.011][request][INFO] POST /api/accounts/verify-email
[2020-10-28 13:57:09.604][bitwarden_rs::api::core::accounts][ERROR] Error sending delete account email: SMTP IO error: Resource temporarily unavailable (os error 11)
[2020-10-28 13:57:09.604][response][INFO] POST /api/accounts/verify-email (post_verify_email) => 200 OK
[2020-10-28 14:39:58.788][request][INFO] POST /api/organizations/XXX/users/XXX/reinvite
[2020-10-28 14:40:18.619][error][ERROR] SMTP IO error: Resource temporarily unavailable (os error 11)
[2020-10-28 14:40:18.619][response][INFO] POST /api/organizations/<org_id>/users/<user_org>/reinvite (reinvite_user) => 400 Bad Request
better for forum question troubleshooting

All 16 comments

This error occurres when the mail server is not reachable or the dns could not be resolved. It can also mean that the port is incorrect for example.

Bitwardenrs can't connect to the mail server for some reason.

Well, I did more test... DNS resolution works inside this container. I tried with curl:
```
jean@nuc /opt/ship/bitwarden $ sudo docker exec -it bitwarden bash
root@BITWARDEN-CONTAINER:/# curl -i ssl0.ovh.net
HTTP/1.1 301 Moved Permanently
Content-length: 0
Location: https://www.ovh.co.uk/mail/
Connection: close
````

I have enabled DEBUG and here is the output (note that sending mail with the same credential work in other container):

[2020-11-06 13:49:57.384][request][INFO] POST /admin/test/smtp/
[2020-11-06 13:49:57.385][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.385][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:49:57.385][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.385][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:49:57.385][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.385][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:49:57.385][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.385][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:49:57.386][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.386][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:49:57.386][handlebars::render][DEBUG] Rendering value: Path(Relative(([Named("url")], "url")))
[2020-11-06 13:49:57.386][handlebars::context][DEBUG] Accessing context value: AbsolutePath(["url"])
[2020-11-06 13:50:17.115][error][ERROR] SMTP IO error: Resource temporarily unavailable (os error 11)
[2020-11-06 13:50:17.116][response][INFO] POST /admin/test/smtp (test_smtp) => 400 Bad Request

My issue is very similar to https://bitwardenrs.discourse.group/t/smtp-unable-to-send-email/145.

This error occurres when the mail server is not reachable or the dns could not be resolved.

The error message is not really clear. For some reason there is no DEBUG message related to SMTP, I find it really strange... Any one that got this error has give up so far since SMTP work with gmail but not with custom SMTP servers...

Any help is welcome 馃槩

I have made progress, I know get this error:

[2020-11-06 15:20:13.166][bitwarden_rs::api::core::accounts][ERROR] Error sending delete account email: SMTP 5xx error: ["5.7.1 Authentication failed"]

I give up on SSL connexion on port 465 and I switched to STARTTLS on port 587. I tested both configuration in other environment: credential are OK. I have no idea why:

  1. I get SMTP IO error: Resource temporarily unavailable (os error 11) for SSL
  2. I get Error sending delete account email: SMTP 5xx error: ["5.7.1 Authentication failed"] for STARTTLS

Same issue.
I try all the possibilities 465/587/25 with ssl, force tls. nothing worked.
Sometimes it's authentication failed, sometimes it's the empty response.

My server and credentials are all double check and ok because i used them on the same server on other services.
Thanks

version docker 1.17.0

I am seeing this as well on our setup. I don't recall seeing it when we were on 1.16.3.

We have an SMTP relay setup that we use. No user authentication, the system is authenticated via IP and just straight send it emails. The host for docker utilizes the same relayhost and we have not seen any DNS resolution errors in the logs for the mail it sends out.

Please try to change or add multiple authentication mechanisms.

My SMTP server sould work only with login method. But I have udated my config with what you requested: "smtp_auth_mechanism": "Login,Plain,Xoauth2",. Still nothing... I get always get Error sending delete account email: SMTP 5xx error: ["5.7.1 Authentication failed"].

hi, thanks for you reply @BlackDex . I try too "Login" and "Plain" mix. It doesn't work.

馃憢 @dani-garcia @BlackDex any update ? No luck on my side 馃様

@jean-io, well, it's hard for us to test user specific configurations of course. And we are limited to the errors we get returned from the email library. I don't know if you are using a mail server under your own control, and if so, please check the logs there.

I don't know if you have tried the option to enable implicit ssl?
Be aware, that the variable name is misleading here.
https://github.com/dani-garcia/bitwarden_rs/blob/e25fc7083de6703af23f576c5d469600c7036254/.env.template#L247

Could it be an underlying DNS/network issue in the container to external resources? As I am having similar issues with this and connecting to a remote mysql database in #1204

@misilot only if you get a message regarding resource unavailable. That could indicate DNS issue or wrong port, or firewall issues etc.. there are also some strange issues sometimes with docker(-compose) and if users fully stop, pull, start it sometimes starts working as it should.

The error regarding credentials is mostly wrong configuration like username, password, auth mechanism or even wrong port.
Strange copy paste issues with passwords or usernames with some special characters can happen and cause issues.

I don't know if you have tried the option to enable implicit ssl?

Not yet! I will try when I get back to home in few days. I hope this will work! 馃ぉ

Regarding copy/paste errors, I will check once again, human error does happen but I already triple checked. 馃お

As a note:
If you are using port 465 kinda dictates that you need Implicit TLS enabled (Thus enable SMTP_EXPLICIT_TLS=true).
When using ports 25 or 587, that means using STARTTLS, which upgrades an existing unencrypted connection to use TLS during the connection.

I have created a PR #1229 which has some changes to enable smtp debugging to troubleshoot issues.

The version with the debug option is available on docker hub when using the testing tag.

https://github.com/dani-garcia/bitwarden_rs/blob/5379329ef71ba4b600eb028d721806a16e62535f/.env.template#L265

Hello,

I just came back from vacation, so it's time to do some SMTP debug.

Good news: with new SMTP debug information from testing image tag, I had more information to resolve this issue, I have found that:

  • with parameter SMTP_EXPLICIT_TLS=true my container is able to open a connection my OVH SMTP server.
  • I have found a mismatch of password between my Bitwarden safe and my Bitwarden config 馃挬 ... @BlackDex you were right: I owe you a beer 馃嵑

Now I have to find why mails are coming as spam for Bitwarden and not for Nextcloud...

Thank you all for your help !

Was this page helpful?
0 / 5 - 0 ratings