SequelizeConnectionRefusedError
Hello, I'm trying to use Neon with Sequelize and keep running into a
[SequelizeConnectionRefusedError]. Migration and seeding with Sequelize's CLI both work, but when I try to access the database while the main application is running—e.g. by calling the model's findOne, findAll, create, or bulkCreate method—I hit the error, even though findOne and bulkCreate work during seeding.
My Sequelize config.js:
And my .env:
I tried adding &connect_timeout=10 to my URL, but nothing changed, so I'm guessing it isn't a timeout error. Unfortunately, I can only see the Sequelize error, not the Neon response that triggers it, which has made troubleshooting difficult. Any help would be appreciated.
(Full error below.)5 Replies
genetic-orangeOP•15mo ago
fair-rose•15mo ago
@Joy hi friend, it looks like you have the postgres address set to localhost. I would check your environment variables, my guess is how ever you set them for seeding clearly works, how ever you set them for your regular application is either not set or not set correctly. ::1 is ipv6 for the localhost or loopback address
genetic-orangeOP•15mo ago
Huh! thanks, I'll try to figure out how that happened
solution: My Sequelize config needed a
host property, and I needed PGHOST, PGDATABASE, PGUSER, and PGPASSWORD variables. Everything's working now.
(thanks again for the help! it got me looking in the right places)flat-fuchsia•15mo ago
GitHub
examples/with-sequelize/index.js at main · neondatabase/examples
Examples and code snippets demonstrating common ways of integrating Neon with various frameworks and languages. - neondatabase/examples
flat-fuchsia•15mo ago
you may use something like the following instead of destructing the environment variables