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

[CAL-2986] After migration appears error connecting to engine PostgreSQL #11911

Closed
scebll opened this issue Oct 16, 2023 · 19 comments · Fixed by #12437
Closed

[CAL-2986] After migration appears error connecting to engine PostgreSQL #11911

scebll opened this issue Oct 16, 2023 · 19 comments · Fixed by #12437
Labels
🐛 bug Something isn't working foundation 🙋🏻‍♂️help wanted Help from the community is appreciated linear Sync Github Issue from community members to Linear.app Low priority Created by Linear-GitHub Sync self-hosting
Milestone

Comments

@scebll
Copy link

scebll commented Oct 16, 2023

Issue Summary

We have recently upgraded from version 3.1.9 to version 3.3.9 and since the upgrade we are seeing many errors in the console that are flooding the service and appears randomly some seconds/minutes after start.

Apparently it appears to be connecting to a database on localhost (::1) when we are using an external postgresql outside of even the kubernetes service where it is running.

This has been running for the past months without problem at all.

Could it be that some change has been made that I missed in the changelog and is producing this error? There's not much detail either and even increasing the debug level doesn't show any errors other than these lines.

Steps to Reproduce

It also appears that the update migrations have been successful (or so we believe) and we are not able to reproduce the error as such, it just appears.

  1. Container starts
  2. A few seconds/minutes later the error starts to appear.

Actual Results

  • No errors at all.

Expected Results

  • A more detailed of the error or the error not-present at all.

Technical details

  • Cal.com version 3.3.9.
  • PostgreSQL 13.5.
  • Kubernetes 1.26.8 (rke2r1) (we know that is build for docker, but runs smoothly so far).

Current environment variables are like this:

CALENDSO_ENCRYPTION_KEY: <hidden>
DATABASE_URL: postgresql://calcom:password@postgres.database.dns/calcom
EMAIL_FROM: <hidden>
EMAIL_SERVER_HOST: <hidden>
EMAIL_SERVER_PASSWORD: <hidden>
EMAIL_SERVER_PORT: "587"
EMAIL_SERVER_USER: <hidden>
JITSI_HOST_URL: <hidden>
NEXT_PUBLIC_LICENSE_CONSENT: true
NEXT_PUBLIC_WEBAPP_URL: <hidden>
NEXTAUTH_SECRET: <hidden>
NODE_ENV: production

Evidence

The error is this one:

@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432
@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432
@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432
[..]

Attached the log of the application running.

calcom-calcom-app-6bcfd55fc5-m4r66-1697453038413861000.log

CAL-2986

@maige-app maige-app bot added the 🐛 bug Something isn't working label Oct 16, 2023
@github-actions
Copy link
Contributor

Thank you for opening your first issue, one of our team members will review it as soon as it possible. ❤️🎉

@PeerRich
Copy link
Member

it looks like it cant connect to the database. did something change?

@PeerRich PeerRich added 🐛 bug Something isn't working 🙋🏻‍♂️help wanted Help from the community is appreciated Low priority Created by Linear-GitHub Sync and removed 🐛 bug Something isn't working labels Oct 17, 2023
@gitwittidbit
Copy link

Seeing this, too, after upgrading to 3.3.7 (docker).

The only (conscious) change was this upgrade.

@notflip
Copy link

notflip commented Oct 18, 2023

Same here! I keep seeing this logged in the console, on the latest version (the app does seem to work?)

@rtpa25
Copy link
Contributor

rtpa25 commented Oct 20, 2023

Fixed this if you check logs inside the postgres container it said
Screenshot 2023-10-20 at 7 10 02 AM
After some tweeks to the docker compose file inside the prisma package
Screenshot 2023-10-20 at 7 14 01 AM
Making a pr asap

@gitwittidbit
Copy link

Thanks rtpa25

But in my case, I did and do not see the errors in the database container log you are showing in your second screenshot. The logs of my database container do not contain anything suspicious at all.

So yours might be a different issue than mine :(

@rtpa25
Copy link
Contributor

rtpa25 commented Oct 20, 2023

Second container ss is all good first one is the actual issue that is being discussed, for which I shot a PR

@gitwittidbit
Copy link

Sorry, I meant the first screenshot (the of your database container).
I don't see those errors in my database container.

@rtpa25
Copy link
Contributor

rtpa25 commented Oct 21, 2023

Sorry for the late reply @gitwittidbit can you share your container logs, and further can you try the changes in #12010 in your local system to test if it solves the problem?

@Hybes
Copy link
Contributor

Hybes commented Oct 27, 2023

same here with @gitwittidbit im not getting the same errors as your first image. but i am getting @calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED 127.0.0.1:5432 about 5 times per second. however, my DB is on a different IP, so im not sure why it's trying to connect to 127.0.0.1?

@gitwittidbit
Copy link

Sorry for the late reply @gitwittidbit can you share your container logs, and further can you try the changes in #12010 in your local system to test if it solves the problem?

Well, I just pulled the current docker images and - what can I say? The error is gone. My logs are not flooded anymore with the error connecting to engine.

Guess your fix did the trick. Thanks!

@icsy7867
Copy link

I am getting these errors as well.

Settings are saving, but it looks like things are trying to connect on localhost ipv6? Very strange.

@cpunnelliehealth
Copy link

cpunnelliehealth commented Dec 3, 2023

I'm getting this error as well. Connection is fine to the db and it's retrieving and saving data okay, but it still shows this error about once every two seconds:

@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432

I'm not running in a docker container.

@icsy7867
Copy link

icsy7867 commented Dec 3, 2023

I'm getting this error as well. Connection is fine to the db and it's retrieving and saving data okay, but it still shows this error about once every two seconds:

@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432

I'm not running in a docker container.

The only thing I can see that references local host and 5432 (postgres port) is this

default: "postgresql://postgres:@localhost:5432/calendso"

@cpunnelliehealth
Copy link

I'm getting this error as well. Connection is fine to the db and it's retrieving and saving data okay, but it still shows this error about once every two seconds:

@calcom/web:start: error connecting to engine: sql, type: postgres db: Error: connect ECONNREFUSED ::1:5432

I'm not running in a docker container.

I notice this happens after a user logs in. If they are already in a session, the error doesn't display until next time they logout/login.

@cpunnelliehealth
Copy link

I found another issue thread with the same issue and came across this fix -- it seems to work for me and resolved this issue:

#12437

@sneko
Copy link

sneko commented Dec 6, 2023

Also having this issue after upgrading... waiting for an official fix 👍

@MehulZR MehulZR mentioned this issue Dec 8, 2023
2 tasks
@xcellentavi
Copy link

I'm also getting the flood of ECONNREFUSED when trying to log in. If I don't navigate to /auth/login page, it doesn't show up. I think it's related to the NEXTAUTH_URL variable. If I use http://serverIP:PORT/api/auth, then I get these errors. If I change to https://my.domain.com/api/auth, no issues logging and or getting any ECONNREFUSED errors. However, the client fetch error eventually surfaces which is only resolved by switching back to http://serverIP:PORT/api/auth.

Any advice or is this just me?

@kart1ka
Copy link
Contributor

kart1ka commented Dec 23, 2023

I am getting the same error too. Although I am using supabase cloud db instead of docker container.

@Udit-takkar Udit-takkar added the linear Sync Github Issue from community members to Linear.app label Jan 21, 2024
@Udit-takkar Udit-takkar changed the title After migration appears error connecting to engine PostgreSQL [CAL-2986] After migration appears error connecting to engine PostgreSQL Jan 21, 2024
@Udit-takkar Udit-takkar added the Medium priority Created by Linear-GitHub Sync label Jan 21, 2024
@Udit-takkar Udit-takkar added this to the v.7 milestone Jan 21, 2024
@Udit-takkar Udit-takkar removed the Medium priority Created by Linear-GitHub Sync label Jan 21, 2024
@keithwillcode keithwillcode modified the milestones: v.7, v3.8 Jan 22, 2024
@Udit-takkar Udit-takkar removed this from the v3.8 milestone Jan 22, 2024
@keithwillcode keithwillcode added this to the v3.8 milestone Jan 22, 2024
@Udit-takkar Udit-takkar modified the milestones: v3.8, v.7 Jan 22, 2024
@keithwillcode keithwillcode modified the milestones: v.7, v3.7 Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working foundation 🙋🏻‍♂️help wanted Help from the community is appreciated linear Sync Github Issue from community members to Linear.app Low priority Created by Linear-GitHub Sync self-hosting
Projects
None yet
Development

Successfully merging a pull request may close this issue.