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

backend can't connect to MongoDB? #351

Closed
dwmct opened this issue Feb 3, 2023 · 3 comments
Closed

backend can't connect to MongoDB? #351

dwmct opened this issue Feb 3, 2023 · 3 comments

Comments

@dwmct
Copy link

dwmct commented Feb 3, 2023

At first, all I noticed was that the "login" button on the frontend did nothing. After poking around I eventually found that the backend container had exited, and found the following in the log:

api@0.0.1 start:prod
node dist/main
[Nest] 17 - 02/03/2023, 5:42:58 PM LOG [NestFactory] Starting Nest application...
[Nest] 17 - 02/03/2023, 5:42:58 PM LOG [InstanceLoader] MongooseModule dependencies initialized +570ms
[Nest] 17 - 02/03/2023, 5:42:58 PM LOG [InstanceLoader] PassportModule dependencies initialized +8ms
[Nest] 17 - 02/03/2023, 5:42:58 PM LOG [InstanceLoader] JwtModule dependencies initialized +4ms
[Nest] 17 - 02/03/2023, 5:43:29 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (1)...
[Nest] 17 - 02/03/2023, 5:44:02 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (2)...
[Nest] 17 - 02/03/2023, 5:44:35 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (3)...
[Nest] 17 - 02/03/2023, 5:45:08 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (4)...
[Nest] 17 - 02/03/2023, 5:45:42 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (5)...
[Nest] 17 - 02/03/2023, 5:46:16 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (6)...
[Nest] 17 - 02/03/2023, 5:46:49 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (7)...
[Nest] 17 - 02/03/2023, 5:47:22 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (8)...
[Nest] 17 - 02/03/2023, 5:47:55 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (9)...
[Nest] 17 - 02/03/2023, 5:47:55 PM ERROR [ExceptionHandler] connect ECONNREFUSED 172.29.16.2:27017
MongooseServerSelectionError: connect ECONNREFUSED 172.29.16.2:27017
at NativeConnection.Connection.openUri (/node_modules/mongoose/lib/connection.js:824:32)
at Mongoose.createConnection (/node_modules/mongoose/lib/index.js:359:10)
at Function. (/node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:62:69)
at Generator.next ()
at /node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:20:71
at new Promise ()
at __awaiter (/node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:16:12)
at /node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:61:80
at Observable._subscribe (/node_modules/rxjs/dist/cjs/internal/observable/defer.js:8:31)
at Observable._trySubscribe (/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)

I imagine being unable to connect to MongoDB is why it exited & stopped the container, but I have no idea why it did that. I added this as a "stack" via Portainer using the "repository" option, where it pulls the docker-compose file straight from your git repository. I'm sure this is just something stupid I'm doing wrong, but any insight would be lovely.

@sauceboss43
Copy link

Not sure if this will help you, but I just had this issue as well, turns out the newest MongoDB requires your processor to be able to run AVX which mine does not so I rolled MonogDB back to version 4 and it got past that error. Now I am having the same issue as #256.

@olealgoritme
Copy link

try adding directConnection=true to the connection string, if using mongoose version 9.

@georgegebbett
Copy link
Owner

Hi all - apologies for the delay on this one - I have just released V2 of Recipe Buddy which removes the dependency on Mongo and should therefore run on a much wider range of devices - please do give it a go and let me know what you think :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants