Question

Why SendGrid and mailchimp are responding with Timeout on DigitalOcean droplet?

Posted May 4, 2021 281 views
NginxNode.jsDockerFirewallDigitalOcean Droplets

I have an express server running on a docker container, and using nginx for reverse proxy and https.

Dockerfile

FROM node:alpine as BUILD_IMAGE

WORKDIR /usr/src/app

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

COPY . .

EXPOSE 5000

CMD ["yarn", "start"]

docker-compose.yml

api_server:
    container_name: api-server
    restart: always
    build: ./server-api/
    ports:
      - '5000:5000'
    depends_on:
      - postgres
      - redis
      - url_server
      - og_server

I am using nodemailer sendgrid to send emails and also using mailchimp but both are not working.

This is the logs:

mailchimp err Error: Timeout of 120000ms exceeded
    at RequestBase._timeoutError (/**/**/app/node_modules/superagent/lib/request-base.js:613:13)
    at Timeout.<anonymous> (/**/**/app/node_modules/superagent/lib/request-base.js:628:12)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7) {
  timeout: 120000,
  code: 'ECONNABORTED',
  errno: 'ETIME',
  response: undefined
}

Fail to send email {
  err: Error: connect ETIMEDOUT 3.64.200.27:443
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:131:14) {
    errno: -110,
    code: 'ETIMEDOUT',
    syscall: 'connect',
    address: '3.64.200.27',
    port: 443
  }
}

This is my ufw status:

To                         Action      From
--                         ------      ----
22/tcp                     LIMIT       Anywhere
2375/tcp                   ALLOW       Anywhere
2376/tcp                   ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
465                        ALLOW       Anywhere
25                         ALLOW       Anywhere
587                        ALLOW       Anywhere
22/tcp (v6)                LIMIT       Anywhere (v6)
2375/tcp (v6)              ALLOW       Anywhere (v6)
2376/tcp (v6)              ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)
465 (v6)                   ALLOW       Anywhere (v6)
25 (v6)                    ALLOW       Anywhere (v6)
587 (v6)                   ALLOW       Anywhere (v6)

I tried to run the container on my local machine (windows 10) and everything works fine email was sent and mailchimp works too, but on DO droplet it didn’t work.

Any ideas? thanks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
3 answers

I found the issue it’s the iptables

sudo nano /etc/docker/daemon.json

{ "iptables": false }

I change it to true

{ "iptables": true}

sudo service docker restart

It was me who alter the iptables to false because I was trying to prevent Docker from bypassing UFW and directly alters iptables.

Now it’s working

Hi there,

As far as I can see from the error, the outgoing connection on port 443 is failing.

I would recommend allowing that port via UFW as well as it is currently not in the list that you’ve provided.

Let me know how it goes.
Regards,
Bobby

  • Hello Bobby thank you for your time.

    Unfortunately still didn’t work for me same error

    I run

    sudo ufw allow 443

    ufw status:

    22/tcp                     LIMIT       Anywhere
    2375/tcp                   ALLOW       Anywhere
    2376/tcp                   ALLOW       Anywhere
    Nginx Full                 ALLOW       Anywhere
    465                        ALLOW       Anywhere
    25                         ALLOW       Anywhere
    587                        ALLOW       Anywhere
    443                        ALLOW       Anywhere
    80                         ALLOW       Anywhere
    22/tcp (v6)                LIMIT       Anywhere (v6)
    2375/tcp (v6)              ALLOW       Anywhere (v6)
    2376/tcp (v6)              ALLOW       Anywhere (v6)
    Nginx Full (v6)            ALLOW       Anywhere (v6)
    465 (v6)                   ALLOW       Anywhere (v6)
    25 (v6)                    ALLOW       Anywhere (v6)
    587 (v6)                   ALLOW       Anywhere (v6)
    443 (v6)                   ALLOW       Anywhere (v6)
    80 (v6)                    ALLOW       Anywhere (v6)
    
    

    I am also using mixpanel with https protocol and it’s working fine.

    let mixpanel = Mixpanel.init(process.env.MIXPANEL_ID, {
      protocol: 'https'
    });
    

    Regards,
    Larbi

    • Hi there,

      Are you using port 25 or port 587 for your SMTP details?

      I could suggest trying out with 587 because as @KFSys mentioned, port 25 is closed by default on an account level.

      Let me know how it goes.
      Regards,
      Bobby

      • Hello Bobby,

        I am not using port 25 and 587 I opened them in case it will work, mailchimp and Nodemailer sendgrid are using port 443 and I still get timeout which means the requests are blocked from getting out.

        I used wireshark and I didn’t see port 25 or 587 used but 443.

        I using nginx reverse proxy and this is the port for nginx container

        ports:
              - '80:80'
              - '443:443'
              - '5432:5432'
        

        Regards,
        Larbi

        • Hi there Larbi,

          I see, yes that is what I thought also after seeing the initial error.

          What I could suggest is trying to run telnet or MTR from your Droplet to the Mailchimp hostname or IP that you are using and see if you get the connection.

          If not, it might be worth getting in touch with Mailchimp and asking them if they are blocking your IP address.

          Let me know how it goes.
          Regards,
          Bobby

Hi @larbisahli1905,

By default for new accounts, port 25 is closed. I would recommend trying with port 587 instead.

To test if port 587 is open you can run the following command:

telnet Your-IP-Address 587

If port 587 is blocked as well, I’ll recommend contacting DigitalOcean’s support to see if the port can be lifted.

You can reach the support at :

https://www.digitalocean.com/support/

Hope that helps!
- KFSys.

  • Hello @KFSys thank you for your time.

    telnet My-Ip-Address 587
    Unable to connect to remote host: Connection refused

    telnet My-Ip-Address 25
    Connection closed by foreign host.

    The question is will mailchimp and sendgrid work if I opened a support ticket?

    Regards,
    Larbi

    • Opening a support ticket will let you know if the port is blocked on account level or if the issue is somewhere else.

      It’s just a means of eliminating the possibilities of the issues narrowing them down eventually to one.