neo4j-javascript-driver: #The Client is unauthorized due to authentication failure

The client is unauthorized due to authentication failure.

  • Complete Error

  • Neo4jError: The client is unauthorized due to authentication failure. at captureStacktrace (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\neo4j-driver\lib\result.js:277:15) at new Result (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\neo4j-driver\lib\result.js:68:19) at Session._run (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\neo4j-driver\lib\session.js:174:14) at Session.run (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\neo4j-driver\lib\session.js:135:19) at Object.executeCypherQuery (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\middleware\graphDBConnect.js:16:34) at C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\routes\users.js:32:42 at newFn (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\express-async-errors\index.js:16:20) at Layer.handle [as handle_request] (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\Users\sensei infotech\Desktop\hari\expressneo4jcrud\node_modules\express\lib\router\route.js:112:3)
  • My File Where i’m trying to login

const neo4j = require('neo4j-driver');
const config = require('config');
const uri = config.get('dbHost');
const user = config.get('dbUser');
const password = config.get('dbPass');
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password), {
  maxConnectionLifetime: 3 * 60 * 60 * 1000, // 3 hours
  maxConnectionPoolSize: 50,
  connectionAcquisitionTimeout: 2 * 60 * 1000, // 120 seconds
  disableLosslessIntegers: true
});
const session = driver.session();
async function executeCypherQuery(statement, params = {}) {
  try {
    const result = await session.run(statement, params);
    session.close();
    return result;
  } catch (error) {
    throw error; // we are logging this error at the time of calling this method
  }
}
module.exports = { executeCypherQuery };

I’m Using Default Username and Password username : neo4j password : neo4j

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@ddemydenko if the issue was about not overriding the default admin password AND assuming you’re using Docker, you can override the password with:

docker run --env NEO4J_AUTH=neo4j/aNewPassword [...] neo4j:5

I’m not 100% sure it’s related, but you usually have to set the password to a non-default value before being able to connect. Have you tried that?

I’ve tried with a docker instance without set the password and got this:

Neo4jError: Permission denied.

The credentials you provided were valid, but must be changed before you can use this instance. If this is the first time you are using Neo4j, this is to ensure you are not using the default credentials in production. If you are not using default credentials, you are getting this message because an administrator requires a password change.
Changing your password is easy to do via the Neo4j Browser.
If you are connecting via a shell or programmatically via a driver, just issue a `ALTER CURRENT USER SET PASSWORD FROM 'current password' TO 'new password'` statement against the system database in the current session, and then restart your driver with the new password configured.

So, It could be the case of change the password.

The docker run without change the password:

docker run --name neo4j  -p7687:7687 -p7474:7474

The docker run changing the password:

docker run --name neo4j --env NEO4J_AUTH=neo4j/pass -p7687:7687 -p7474:7474