Failed to load resource: the server responded with a status of 401 (Unauthorized)

Hi! Every time I load docker compose up, everything runs correctly, but after a few hours I get this from the Chrome Console: Failed to load resource: the server responded with a status of 401 (Unauthorized). I can create the user and login successfully but after just a couple of hours it deletes my user and I can't continue with anything since I can't access the project anymore, is there a way I can avoid this issue?
16 Replies
Tomer Barnea
Tomer Barnea13mo ago
Hey @nelson_arguera not 100% sure, but is your MongoDB storage is external to the docker? If not make sure to have it external if something failes with the docker daemon. @Pawan Jain @madd any suggestions here?
nelson_arguera
nelson_argueraOP13mo ago
No is not external, I tried loading it from a docker volume and also a mounted folder. Here is the docker compose file @Tomer Barnea : .env file
Tomer Barnea
Tomer Barnea13mo ago
Thanks @nelson_arguera for the information! A quick question, do you see something on your machine here "./data/db"? also, as a small suggestion, use absulte path and not relative one for clearity and to make sure execution context would not change the db storage location. but I'll let @Pawan Jain and @madd to give us more detailed answer if they see something else.
nelson_arguera
nelson_argueraOP13mo ago
Okay thank you @Tomer Barnea ! Yes I see it on the current folder that I have the docker compose, also I tried connecting to my container using docker exec -it xxxxxxxxxx bash then mongosh and it seems like novu deletes everything even old or current users and all data from other collections.
mdd
mdd13mo ago
@nelson_arguera what OS are you using? There is problem inside MongoDB image with mapping host's directory on Mac and Windows
nelson_arguera
nelson_argueraOP13mo ago
I'm using Linux 20.04.1-Ubuntu
Novu_Bot
Novu_Bot13mo ago
@nelson_arguera, you just advanced to level 1!
Pawan Jain
Pawan Jain13mo ago
@nelson_arguera Are you running this in local machine or some remote VM?
nelson_arguera
nelson_argueraOP12mo ago
Google Cloud VM But I never encountered this issue before of running a container and then it empties after a few hours @Pawan Jain
Pawan Jain
Pawan Jain12mo ago
@nelson_arguera Main issue here is public access of mongodb running in container I would recommend to use some inbound outbound rules for db access And use username and password for db
nelson_arguera
nelson_argueraOP12mo ago
Okay got it! Thank you Issue resolved, I had to assign user and pass for mongodb and also the init script
Tomer Barnea
Tomer Barnea12mo ago
Hey @nelson_arguera would you mind sharing with us the scripts you ran (assuming you created a script)?
nelson_arguera
nelson_argueraOP12mo ago
Right now! I thought about doing it but thought it was not required Added MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD and MONGO_INITDB_DATABASE to .env file with default database name as novu-db then on docker-compose.yml on the mongodb image I added the env variables from .env and added the ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro to volumes
Novu_Bot
Novu_Bot12mo ago
@nelson_arguera, you just advanced to level 2!
nelson_arguera
nelson_argueraOP12mo ago
init-mongo.js on the same docker-compose.yml folder
Pawan Jain
Pawan Jain12mo ago
@nelson_arguera Thanks for sharing this approach I updated the example env file in this PR https://github.com/novuhq/novu/pull/5038/files#diff-ec10582dde9af6c0c622084d3244b29d496260613491c430ec8958565e2f31b4R20
Want results from more Discord servers?
Add your server