LoginSignup
0

More than 5 years have passed since last update.

【解決!】Docker上でNodemailerを使うとメールが送信されない

Posted at

タイトル通り、Docker上に立てたAPIサーバーから、メール送信をしようとすると以下のような、エラーがでる

{ Error: getaddrinfo EAI_AGAIN ${SMTP_SERVER}:587
    at Object._errnoException (util.js:1022:11)
    at errnoException (dns.js:55:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
  code: 'ECONNECTION',
  errno: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: '${SMTP_SERVER}',
  host: '${SMTP_SERVER}',
  port: 587,
  command: 'CONN' }

どうやら外部ネットワークに接続できずに、止まってしまっているらしい

別にDockerの設定変更も行っていないのに。。。

nginx再起動してみよ・・・

$ docker-compose restart nginx

docker: Error response from daemon: failed to create endpoint db01 on network bridge: COMMAND_FAILED: '/sbin/iptables -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0' failed: iptables: No chain/target/match by that name..

むむ、そういえばfirewalldをいじったぞ!
Googleさんに聞こう!

突然Dockerコンテナ内からネットワークに繋がらなくなったらiptablesを疑ってみよう
http://blue1st-tech.hateblo.jp/entry/2017/01/29/232733

どうやらfirewalldやiptablesを再起動させたりすると、Docker周りの設定がなくなってしまうようだ。

というこで、

$ systemctl restart docker

Dockerを再起動させたら直りました。

まとめ

iptablesを再起動したら、Dockerの再起動もしましょう!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0