Parse Server "Unable to ensure uniqueness for usernames" - node.js

Me and my partner are having serious issues with MongoDB these days. Suddenly, our Parse Server mounted on MongoDB, in a VPS, started failing. Our app couldn't connect there, nor the Parse Dashboard. Something was failing.
In the parse logs, this is what appears:
{"level":"info","message":"Parse LiveQuery Server starts
running","timestamp":"2017-07-09T20:23:59.711Z"}
{"level":"info","message":"Parse LiveQuery Server starts
running","timestamp":"2017-07-09T20:25:47.884Z"} {"message":"Unable to
ensure uniqueness for usernames:
","name":"MongoError","stack":"MongoError: failed to connect to server
[localhost:27017] on first connect\n at null.
(/home/main/StepApp/node_modules/mongodb-core/lib/$ {"message":"Unable
to ensure uniqueness for user email addresses:
","name":"MongoError","stack":"MongoError: failed to connect to server
[localhost:27017] on first connect\n at null.
(/home/main/StepApp/node_modules/mongod$
We tried this whole bunch of things:
Installing a new MongoDB version
Import the old .db files
Restart our Node.js instancies via pm2
Adding more space to our VPS (it seems MongoDB was having some trouble with disk space, but this is already fixed).
Adding an admin user to our db, with all permissions, and then adding it to the mongodb connection string in our Node file.
After all of this, several server restarts, pm2 restarts, mongo restarts...
... nothing works.
When I restart the server, I receive that strange error string I copied before, though Mongo is working fine.
Seems to be more of a Parse problem... but, why?
Any help will he appreciated!
EDIT / UPDATE:
I've been checking if MongoDB is working, and it's service "mongod" is online. Tried to listen to a different port, changed it too in the index.js mongo connection string, but I keep getting the same error.
Strange thing is, that when I connect to my database with my newly created Mongo user, it authenticates correctly! (I could see it in the logs). So it seems to be a Parse error, somehow it doesn't get the Mongo response or something like that.
What do you think?

Related

How to list MongoDB items of a Local Database?

I've already done my research and have gotten so far...
By entering the commands on mongoDB shell or node, this shows up:
Now the problem is that I actually have users in this DB because I'm testing this on an application on port 3000 localhost. When I try to register the same user a second time, an error shows up, saying that this entry is duplicate.
TL;DR: Mongo says DB is empty when it's not
When you're in the database testForAuth, use the command db.users.find() and it should print out all the users.

How to solve the error SequelizeHostNotFoundError?

Problem essence
Writing the API server in NodeJS (Express) using the PostgreSQL database (connecting to it remotely through the service ElephantSQL and work through Sequelize). Today appeared an error "SequelizeHostNotFoundError". It occurs even in the checked endpoints.
Error text
(it remains only a screenshot of the error)
My attempts to solve the problem
Tried to perform a GET request to my API not via Postman and via the browser (did not help).
Tried to create a new DB on the same service ElephantSQL (didn't help, but migrations to create new tables and relationships somehow executed and endpoints still not working).
Tried to connect to the database directly via IDE DataGrip (connection test is successful and the database is loaded with all the tables).
What could be the problem ? On stackoverflow some wrote that the problem may occur due to the lack of a paid subscription to Google Cloude Functions, but I do not seem to use it. There is an option to connect to PostgreSQL locally, but I want to understand.

Issues with a Node app deployed through elastic beanstalk

I'm deploying a node app to an ec2 instance through aws elastic beanstalk. I set up a cron job with the cron node package that, on tick, will run a sequelize query, parse the data returned, then send it in the body of an email.
When testing locally, it works fine and the email gets sent. When i deploy it using awsebcli command eb deploy, it says the deploy was successful, but I don't receive any emails.
At first I believed the npm start command wasn't working on the server, but I checked the error logs and it appears sequelize is throwing a time out error when trying to connect.
I wrote a configuration for sequelize to connect to multiple schemas at once. Three of those schemas are hosted on the same RDS, one on a seperate RDS.
I've done almost the exact same thing with another node app and it worked fine. The only thing different is the additional schema on a seperate RDS that I'm connecting to fine on my local machine.
Any thoughts or suggestions would be appreciated.
EDIT: Checked server logs and found Sequelize connection error.
Found that the issue was caused by security groups on aws preventing my instance from connecting to one of the DBs it needed.
Edit:
Specifics have been requested. Since this is a very old post and I don't have access to AWS anymore, I can venture a guess on what I did.
If my memory serves correct, the db I was blocked by was hosted in a different aws account. Changing the security group on the DB was not an option as security on that account was firmly maintained. The reason I was able to connect locally was because the facility I was working at had a whitelisted IP on the DB security groups. I eventually settled on running the script on my local machine, since my machine rarely left that location and it did not matter where the script was run, just that it ran periodically. Ideally though, I would have been able to change the security group on the db to allow incoming traffic from my server.

Sails mongodb missing connection handling

Very simple and stupid question I came up with today when was playing around with sails and mongo db (adapter of the waterline odm). I just shut down the mongo while my sails server still has been running and saw nothing, neither in logs of sails or in the browser. How I could handle such situation?
If sails.js attempts a connection to the DB you will most certainly get a message in your console if the Mongo server is shut down, but if no request is made that requires a DB connection, then you will not see any error because no error as of yet exists.
It sounds like you might require a process that will monitor your DB and check to make sure it is still running? There are Sail.js options where you could create a CRON job to check the connection. Or you could use other application monitoring services like New Relic to monitor your DB.

connect to mongodb remotely node.js

I know this is kind of trivial, but I have been searching on google for a solution to this problem, this here is my first time deploying a mongodb+node.js application, I have succeeded in hosting a node.js application with static data, I have changed it to use a database -mongodb, I have created a mongodb database on mongolab.com,
I have tried connecting but I keep getting this error
Database error
Error details: Error: failed to connect to [subdomain.mongolab.com:10027]
I have been searching over google, did not get a solution, have also contacted the site admin, my database connection and the entire code to fetch from mongodb remotely is
here on github , thanks

Resources