Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Calcom resend SMTP connection timed out #5196

Closed
racso-dev opened this issue Feb 21, 2025 · 5 comments
Closed

[Bug]: Calcom resend SMTP connection timed out #5196

racso-dev opened this issue Feb 21, 2025 · 5 comments

Comments

@racso-dev
Copy link

racso-dev commented Feb 21, 2025

Error Message and Logs

When deploying Calcom through available services, I use resend smtp configuration (a valid one, I tested it on other apps and it works just fine) and when Calcom tries to send emails the connection to resend's smtp server times out and therefore no email of any kind can be sent.

Here are my env variables set in configuration of the services :

[email protected]
NEXT_PUBLIC_WEBAPP_URL=https://calendar.tendiz.ai
[email protected]
EMAIL_SERVER_HOST=smtp.resend.com
EMAIL_SERVER_PASSWORD=some_secret_env_var
EMAIL_SERVER_PORT=465
EMAIL_SERVER_USER=resend
POSTGRES_DB=calendso
SERVICE_BASE64_CALCOMKEY=some_secret_env_var
SERVICE_BASE64_CALCOMSECRET=some_secret_env_var
SERVICE_FQDN_CALCOM=https://calendar.tendiz.ai
SERVICE_PASSWORD_POSTGRES=some_secret_env_var
ALLOWED_HOSTNAMES=tendiz.ai
SERVICE_USER_POSTGRES=some_secret_env_var

(The domain is verified on resend)

Here are some logs of an attempt to send an email :

2025-02-06T23:08:00.385171783Z @calcom/web:start: sendEmail from: [email protected] <[email protected]> subject: 30 Min Meeting between Oscar Rénier and Oscar Rénier Error: Connection timeout
2025-02-06T23:08:00.385181451Z @calcom/web:start:     at SMTPConnection._formatError (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:787:19)
2025-02-06T23:08:00.385190068Z @calcom/web:start:     at SMTPConnection._onError (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:773:20)
2025-02-06T23:08:00.385198624Z @calcom/web:start:     at Timeout.<anonymous> (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:232:22)
2025-02-06T23:08:00.385207621Z @calcom/web:start:     at listOnTimeout (node:internal/timers:569:17)
2025-02-06T23:08:00.385216036Z @calcom/web:start:     at process.processTimers (node:internal/timers:512:7) {
2025-02-06T23:08:00.385224432Z @calcom/web:start:   code: 'ETIMEDOUT',
2025-02-06T23:08:00.385232697Z @calcom/web:start:   command: 'CONN'
2025-02-06T23:08:00.385240972Z @calcom/web:start: }

Check that little video if you wanna see the problem "live".
Video (I trimed the video because It took around 2 minutes to timeout)

If you have any ideas on how to troubleshoot that issue I'd truly appreciate It.
Thanks in advance for those reading my post hope someone can help.

Steps to Reproduce

  1. Go on resend.com create an account and an api key (it's free)
  2. Deploy Calcom through Coolify services one click deployment configuring SMTP env variables with resend configuration
  3. Trigger a mail by reserving a slot on any event type of your choice

Example Repository URL

No response

Coolify Version

v4.0.0-beta.394

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 24.04

Additional Information

No response

@racso-dev racso-dev added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Feb 21, 2025
@racso-dev
Copy link
Author

Is anyone having a similar issue? Would be really nice having someone investigate on this ;)

@peterkunsay
Copy link

Hi @racso-dev!

I started to experience the same issue with my Next.js, Nodemailer setup and self hosted coolify.

I have been using this setup without issues for several months, and just started experiencing this issue recently. I think probably one of the last updates is causing the problem.

I am currently running v4.0.0-beta.398 and I am getting the exact same error:

2025-03-21T08:11:53.247971587Z {
2025-03-21T08:11:53.248037691Z   err: Error: Connection timeout
2025-03-21T08:11:53.248043704Z       at k._formatError (.next/server/chunks/8856.js:144:45247)
2025-03-21T08:11:53.248046403Z       at k._onError (.next/server/chunks/8856.js:144:45075)
2025-03-21T08:11:53.248048993Z       at Timeout.<anonymous> (.next/server/chunks/8856.js:144:37058) {
2025-03-21T08:11:53.248051962Z     code: 'ETIMEDOUT',
2025-03-21T08:11:53.248054248Z     command: 'CONN'
2025-03-21T08:11:53.248056633Z   },
2025-03-21T08:11:53.248059618Z   msg: 'Error verifying Nodemailer transport.'
2025-03-21T08:11:53.248062220Z }

When trying to connect to my smtp provider.

@peterkunsay
Copy link

After quite a bit of painstaking head-scratching, I finally managed to solve the issue in my environment.

My first instinct was that Coolify’s proxy might be blocking the port somehow, but after completely disabling the proxy, I discovered the issue was actually one level above.

I SSHed into my VPS and ran telnet smtp.postmarkapp.com 587, the connection timed out. After further investigation, I realized that DigitalOcean recently blocked all outbound traffic for SMTP ports 25, 465, and 587 without sending any warning emails or notices—they just dropped a blog post about it and that's all (DigitalOcean docs).

I switched my applications to use port 2525 for emailing, which Postmark also supports, and the problem was immediately resolved.

Is there any chance you’re using a DigitalOcean Droplet as your hosting?

Could you try running telnet [smtp host] [smtp port] on your machine to see if the connection is blocked?

@racso-dev
Copy link
Author

racso-dev commented Mar 21, 2025

Hi @peterkunsay thanks for taking the time to answer.

My server is hosted on Hetzner and I'm running into this issue with a calcom docker image so probably not the same issue here.

I tried running telnet smtp.resend.com 587 also tried with other allowed ports to connect over TLS (587, 2587, 2465) all those works fine with telnet inside my docker container running the calcom nextjs app, one that doesn't work is the unsecure 465. Here is the trace of my test lmk if you see anything abnormal.

telnet smtp.resend.com 587
Trying 54.205.195.44...
Connected to smtp.resend.com.
Escape character is '^]'.
220 Resend SMTP Relay ESMTP
QUIT
221 Bye
Connection closed by foreign host.

But anyways in my env variables I had set one of the secure ports, actually tried with every available ports but nothing works.
The interesting thing is that I just pulled the latest version of the calcom docker image. And the error kind of slightly evolved. I now get :

2025-03-21T16:40:47.887368781Z @calcom/web:start: sendEmail from: [email protected] <[email protected]> subject: 30 Min Meeting between Oscar Rénier and Oscar Rénier Error: Greeting never received
2025-03-21T16:40:47.887377598Z @calcom/web:start:     at SMTPConnection._formatError (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:787:19)
2025-03-21T16:40:47.887383699Z @calcom/web:start:     at SMTPConnection._onError (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:773:20)
2025-03-21T16:40:47.887389450Z @calcom/web:start:     at Timeout.<anonymous> (/calcom/node_modules/nodemailer/lib/smtp-connection/index.js:707:22)
2025-03-21T16:40:47.887396222Z @calcom/web:start:     at listOnTimeout (node:internal/timers:569:17)
2025-03-21T16:40:47.887401713Z @calcom/web:start:     at process.processTimers (node:internal/timers:512:7) {
2025-03-21T16:40:47.887407254Z @calcom/web:start:   code: 'ETIMEDOUT',
2025-03-21T16:40:47.887412934Z @calcom/web:start:   command: 'CONN'
2025-03-21T16:40:47.887418304Z @calcom/web:start: }

Let me know if you have any ideas.

If anyone else runs into a similar issue feel free to engage!

@racso-dev
Copy link
Author

Not entirely sure why, but it seems that the issue has been fixed in a recent update.
I got It to work by using port 587 instead of 2465.
Closing this as the connection doesn't time out anymore and emails are now being sent correctly with Resend's SMTP.

@github-actions github-actions bot removed 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants