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

Cannot connect to Postgres database when deployed, but works on the local machine #3177

Open
transcendr opened this issue Sep 11, 2024 · 8 comments
Labels
bug Something isn't working question Further information is requested

Comments

@transcendr
Copy link

Describe the bug
Since upgrading to version 2.0.7 in order to get a fix for a bug related to credentials resetting, I've not been able to connect to my Postgres database when FlowWise is deployed to GCP. The environment variables are set. There's a .env file in both the docker folder and the server folder, just to be sure. This setup with these particular environment variables was working before when I had version 1.7.2 installed, deployed originally. But now after version 2.0.7, when I redeploy to GCP, there are no errors but my chat flows, credentials, etc. that are stored in the database are not retrieved (at least it appears so). They're not available and not visible in the UI.

Here are the variables that I have set associated with the database. Obviously, I've replaced the actual values with zeros. But you can see here what I actually have set:

image

Again, I want to stress that I don't see anything in the logs indicating that there's an error or issue establishing a connection with the database. So I'm not really sure what's going on. Also, if I run Flowise locally and access it on localhost, the connection appears to be established correctly because all of my chat flows and everything else that I've saved in Flow are available and can be edited. Could it be that GCP is for some reason not picking up the environment variables, or something else?

To Reproduce
Clone the latest version of Flowise version 2.0.7 and add the.env file with the above structured environment variables for the database. Follow the documentation for deploying to GCP on Kubernetes. Access the application via its external IP. Create a new chat flow, and you will see that the chat flow is indeed saved. I suspect it is saved to some local database or file system, Or do any other action that would typically update the database. You should see that the connection is not established.

Expected behavior
Flowise is connected to the Postgres database.

Screenshots
none

Flow
n/a

Setup
n/a

Additional context
none


@transcendr
Copy link
Author

I just confirmed by rolling back to 1.7.2 it is working again with the same config vars.

@HenryHengZJ
Copy link
Contributor

how are you installing Flowise? Docker, npx, or git?

@transcendr
Copy link
Author

transcendr commented Sep 12, 2024

git clone, checking out the version tag, but deployment to GCP is via Docker.

@HenryHengZJ
Copy link
Contributor

does it work when setting up locally? we havnet changed anything on the backend database side, so it should still be the same as before

@HenryHengZJ HenryHengZJ added bug Something isn't working question Further information is requested labels Sep 13, 2024
@transcendr
Copy link
Author

@HenryHengZJ yes when building and running locally there is no issue. It's only when it's deployed to GCP that it doesn't seem to connect. I have a suspicion that it has something to do with the environment variables not being picked up for it, but there are no errors in the logs related to failed db connection, etc. There's also at least some db connected (sqlite?) because I can create new entities and they persist for a little while (eventually they get cleared, probably because of the ephemeral state of the container, but it's not clear to me when GCP clears it).

@HenryHengZJ
Copy link
Contributor

So it might be related to how GCP is picking up those env variables from Docker. Does your docker-compose.yml has the correct env variables passed in?
image

@transcendr
Copy link
Author

@HenryHengZJ yep, here's my docker-compose.yml

image

Yes, these were passed into my Docker Compose, but I also noticed that that particular variable is not included in my .env file. However, it has never been included in my .env file, and version 1.7.1 works without it, which when deployed to GCP does connect correctly to the database. As a note, that database path variable seems to be taken into account in the newer version because I do have persistence, but I think it's the sqlite db persisting data because it's obviously not data from my Postgres database.

Additionally, I noticed that where that database_path environment variable is referenced, in Datasource.ts, it's only referenced for SQLite and not for Postgres.

@transcendr
Copy link
Author

transcendr commented Oct 14, 2024

Did try deploying the latest version again and am now getting connection refused error for the postgres connection now:
image
This error never appeared in my previous attempts, and now clearly GCP is recognizing the env variables, so that's good. Given our config, can you spot any potential issue, @HenryHengZJ ?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants