https://prefect.io logo
Title
a

Alexis Lucido

11/24/2021, 12:52 PM
Hi all. Another question. Sorry for bothering. So I am trying to use a custom PostgreSQL database. I have set the a prefectdb postgre db with a username prefect and a given password. I have add the following lines of code into my config.toml file: [server.database] connection_url = "postgres://prefect:_mypassword_@0.0.0.0:5432/prefectdb" I launch my server with the command : prefect server start --external-postgres --expose However, I have the following error log coming up: hasura_1 | {"internal":"could not connect to server: Connection refused\n\tIs the server running on host \"0.0.0.0\" I believe there is a mistake in my host definition, or a docker container link issue. I have tried to replace 0.0.0.0 with localhost and the hostname of my virtual machine, but I still find the same problem. Is there any more changes to add to the prefect server config file? Moreover, I have another error with the graphql container: Error: Can't load plugin: sqlalchemy.dialects:postgres And I am wondering whether I should set the connection_url element in config.toml as connection_url = "postgresql://...", as stated here: https://stackoverflow.com/questions/62688256/sqlalchemy-exc-nosuchmoduleerror-cant-load-plugin-sqlalchemy-dialectspostgre Could you please help me solve that issue? Thanks in advance, again!
a

Anna Geller

11/24/2021, 1:08 PM
There are several issues here: 1. Is your Postgres database simply running on the same machine? The error suggests that the Server running in a container cannot reach the database running on the same host but outside of the container. This is normal. You could set up a database from some cloud provider e.g. AWS RDS or GCP Cloud Spanner. 2. The sqlalchemy error looks like a result of missing Python dependencies - I believe you would need to install sqlalchemy and psycopg2 3. The connection looks OK to me, except that the host name is not good. You shouldn’t use a local database running on a host inside of Server running in a container, this won’t work. Instead, either provision a database instance in some cloud service and set the hostname in place of 0.0.0.0 (it could be: “`postgres://user:password@database-1.some_host_name.us-east-1.rds.amazonaws.com:5432/prefectdb`”) or use the postgres database running as part of the default docker-compose setup
a

Alexis Lucido

11/25/2021, 1:51 PM
Thank you very much Anna. I ended using the classic postgre container set up with prefect server, and persisting the database
🙌 1