W
Wasp2mo ago
ayo

PgBoss error during deployment

I'm getting the following errors while attempting to deploy the backend of my appilcaition. I'm using aws rds to host the db. Apollgies the errors are not parsed properly.
error: no pg_hba.conf entry for host "172.31.0.212", user "*****", database "****", no encryption
error: no pg_hba.conf entry for host "172.31.0.212", user "*****", database "****", no encryption
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<PgBoss>".] {
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<PgBoss>".] {
code: 'ERR_UNHANDLED_REJECTION'
code: 'ERR_UNHANDLED_REJECTION'
Keep in. mind this error happens after migrations are complete
6 Replies
kapa.ai
kapa.ai2mo ago
Hi @ayo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can offer some insights into your PgBoss error during deployment. It appears you're encountering issues related to database connectivity and PgBoss configuration when deploying your Wasp application. The error messages you're seeing suggest two main problems: 1. A database connection issue:
error: no pg_hba.conf entry for host "172.31.0.212", user "*****", database "****", no encryption

error: no pg_hba.conf entry for host "172.31.0.212", user "*****", database "****", no encryption

This error indicates that your PostgreSQL server's pg_hba.conf file doesn't have an entry allowing connections from your application's host. 2. An unhandled promise rejection related to PgBoss:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<PgBoss>".] {
code: 'ERR_UNHANDLED_REJECTION'

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<PgBoss>".] {
code: 'ERR_UNHANDLED_REJECTION'

To address these issues, you might want to try the following: 1. Ensure that your AWS RDS PostgreSQL instance is configured to allow connections from your application's IP address. You may need to update the security group rules for your RDS instance. 2. Check your database connection string. As mentioned in the Heroku deployment guide (https://wasp-lang.dev/docs/advanced/deployment/manually#deploy-to-a-heroku-app), when using PgBoss (which Wasp uses for jobs), you might need to set an additional environment variable:
PG_BOSS_NEW_OPTIONS={"connectionString":"<YOUR_DATABASE_URL>","ssl":{"rejectUnauthorized":false}}

PG_BOSS_NEW_OPTIONS={"connectionString":"<YOUR_DATABASE_URL>","ssl":{"rejectUnauthorized":false}}

This configuration helps PgBoss connect to the database over SSL, which might be required by your AWS RDS setup. 3. Make sure your DATABASE_URL environment variable is correctly set with the proper connection string for your AWS RDS instance. 4. If you're using Wasp's job feature, ensure that the job declarations in your .wasp file are correct and that you have the necessary configurations for PgBoss. If these steps don't resolve the issue, you might want to check your application's error handling, particularly around database connections and job initializations, to catch and properly handle any potential errors. Remember, deploying to a cloud environment can sometimes reveal issues that weren't apparent in local development. If you continue to face problems, you might want to review your deployment process and ensure all necessary environment variables and configurations are correctly set for your production environment. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ayo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
ayo
ayoOP2mo ago
I solved this by adding ?sslmode=no-verify to the db connection string. I think it works for dev phase
Filip
Filip2mo ago
Very strange... Seems like the credentials are wrong, but the migration has already finished? Did I get that correctly?
ayo
ayoOP2mo ago
Not a credential issue as the migration happens. My guess is some DB providers by default require ssl connections, while some don't. So I guess my question is how does wasp handle ssl connections for db out of the box?
miho
miho2mo ago
So I guess my question is how does wasp handle ssl connections for db out of the box?
We using Prisma as our database abstraction layer, so the question is how does Prisma handle SSL connections out of the box. https://www.prisma.io/docs/orm/overview/databases/postgresql the default seems to be prefer
PostgreSQL database connector | Prisma Documentation
This page explains how Prisma can connect to a PostgreSQL database using the PostgreSQL database connector.
miho
miho2mo ago
On the other hand, PgBoss connects to the DB using node-postgres and I'm not sure what's their default SSL option - I guess the same. https://node-postgres.com/features/ssl

Did you find this page helpful?