Better AuthBA
Better Auth•6mo ago
pm

better-auth cli failing with ECONREFUSED

Hello i am having an issue initially setting up better auth for a trial. The cli generate command is failing with spurious looking errors.

node: 22.17.1
nextjs: ^15.0.3
cli: latest
DB: postgresql
OS: MacOs 15.5

The auth is working successfully with memory adapter.
The database connection seems to connect successfully to the db instance when running the app normally (i receive a cannot find db does not exsist error which is expected as i have not created the db yet).

However when i run the cli generate command i get a couple of odd errors, weather i specify config location or not.

I have tried adding the env vars to my env as the error seems to indicate they are not being set due to the starting warning of "Social provider microsoft is missing clientId or clientSecret" and that it is trying to connect to a DB on localhost and not the one specified.

Logs and auth.ts in reply as too long for discord.
Solution
Yeah it looks like it might be an ENV issue. Usually it's able to import
.env
files automatically tho, could it be that you have a different file name or using a different framework? šŸ¤”
Was this page helpful?