syxolk / euro2024

Euro 2024: Betting with your friends
https://www.wetten2024.de
52 stars 22 forks source link

Unhandled rejection SequelizeConnectionError: password authentication failed for user "euro2016" #11

Closed Rafnuss closed 8 years ago

Rafnuss commented 8 years ago

Hi, Thank you very much for this code! This is really cool! I'm trying to install in on a VPS but I'm getting this error.

I have set the config file :

module.exports =
    # URL origin of the web server
    origin: 'http://localhost:8080'

    # PostreSQL connection URL
    db: 'postgres://euro2016:2016@localhost:5432/euro2016'

When I run nodejs index.js, I get: Unhandled rejection SequelizeConnectionError: password authentication failed for user "euro2016"

If try to directly open the database from node js, it seems to work:

var sequelize = new Sequelize("postgres://euro2016:2016@localhost:5432/euro2016",{})
{ options: 
   { dialect: 'postgres',
     dialectModulePath: null,
     host: 'localhost',
     protocol: 'tcp',
     define: {},
     query: {},
     sync: {},
     timezone: '+00:00',
     logging: [Function: bound ],
     omitNull: false,
     native: false,
     replication: false,
     ssl: undefined,
     pool: {},
     quoteIdentifiers: true,
     hooks: {},
     retry: { max: 5, match: [Object] },
     transactionType: 'DEFERRED',
     isolationLevel: 'REPEATABLE READ',
     databaseVersion: 0,
     typeValidation: false,
     benchmark: false,
     port: '5432' },
  config: 
   { database: 'euro2016',
     username: 'euro2016',
     password: '2016',
     host: 'localhost',
     port: '5432',
     pool: {},
     protocol: 'tcp',
     native: false,
     ssl: undefined,
     replication: false,
     dialectModulePath: null,
     keepDefaultTimezone: undefined,
     dialectOptions: undefined },
  dialect: 
   { sequelize: [Circular],
     connectionManager: 
      { sequelize: [Circular],
        config: [Object],
        dialect: [Circular],
        versionPromise: null,
        dialectName: 'postgres',
        onProcessExit: [Function: bound ],
        lib: [Object],
        pool: [Object] },
     QueryGenerator: 
      { options: [Object],
        extractTableDetails: [Function],
        addSchema: [Function],
        dropSchema: [Function],
        createTableQuery: [Function],
        versionQuery: [Function],
        describeTableQuery: [Function],
        dropTableQuery: [Function],
        renameTableQuery: [Function],
        showTablesQuery: [Function],
        addColumnQuery: [Function],
        removeColumnQuery: [Function],
        changeColumnQuery: [Function],
        renameColumnQuery: [Function],
        insertQuery: [Function],
        bulkInsertQuery: [Function],
        updateQuery: [Function],
        upsertQuery: [Function],
        deleteQuery: [Function],
        incrementQuery: [Function],
        nameIndexes: [Function],
        addIndexQuery: [Function],
        showIndexesQuery: [Function],
        removeIndexQuery: [Function],
        attributesToSQL: [Function],
        findAutoIncrementField: [Function],
        quoteTable: [Function],
        quote: [Function],
        createTrigger: [Function],
        dropTrigger: [Function],
        renameTrigger: [Function],
        createFunction: [Function],
        dropFunction: [Function],
        renameFunction: [Function],
        quoteIdentifier: [Function],
        quoteIdentifiers: [Function],
        escape: [Function],
        getForeignKeysQuery: [Function],
        dropForeignKeyQuery: [Function],
        selectQuery: [Function],
        getQueryOrders: [Function],
        selectFromTableFragment: [Function],
        joinIncludeQuery: [Function],
        setAutocommitQuery: [Function],
        setIsolationLevelQuery: [Function],
        startTransactionQuery: [Function],
        deferConstraintsQuery: [Function],
        setConstraintQuery: [Function],
        setDeferredQuery: [Function],
        setImmediateQuery: [Function],
        commitTransactionQuery: [Function],
        rollbackTransactionQuery: [Function],
        addLimitAndOffset: [Function],
        handleSequelizeMethod: [Function],
        whereQuery: [Function],
        whereItemsQuery: [Function],
        whereItemQuery: [Function],
        getWhereConditions: [Function],
        booleanValue: [Function],
        dialect: 'postgres',
        setSearchPath: [Function],
        createSchema: [Function],
        showSchemasQuery: [Function],
        parseConditionObject: [Function],
        fn: [Function],
        exceptionFn: [Function],
        attributeToSQL: [Function],
        databaseConnectionUri: [Function],
        pgEscapeAndQuote: [Function],
        expandFunctionParamList: [Function: expandFunctionParamList],
        expandOptions: [Function: expandOptions],
        decodeTriggerEventType: [Function: decodeTriggerEventType],
        triggerEventTypeIsConstraint: [Function: triggerEventTypeIsConstraint],
        expandTriggerEventSpec: [Function: expandTriggerEventSpec],
        pgEnumName: [Function],
        pgListEnums: [Function],
        pgEnum: [Function],
        pgEnumAdd: [Function],
        pgEnumDrop: [Function],
        fromArray: [Function],
        padInt: [Function],
        dataTypeMapping: [Function],
        _dialect: [Circular],
        sequelize: [Circular],
        typeValidation: undefined } },
  models: {},
  modelManager: { models: [], sequelize: [Circular] },
  connectionManager: 
   { sequelize: [Circular],
     config: 
      { database: 'euro2016',
        username: 'euro2016',
        password: '2016',
        host: 'localhost',
        port: '5432',
        pool: [Object],
        protocol: 'tcp',
        native: false,
        ssl: undefined,
        replication: false,
        dialectModulePath: null,
        keepDefaultTimezone: undefined,
        dialectOptions: undefined },
     dialect: 
      { sequelize: [Circular],
        connectionManager: [Circular],
        QueryGenerator: [Object] },
     versionPromise: null,
     dialectName: 'postgres',
     onProcessExit: [Function: bound ],
     lib: 
      EventEmitter {
        domain: [Object],
        _events: {},
        _eventsCount: 0,
        _maxListeners: undefined,
        defaults: [Object],
        Client: [Object],
        Query: [Object],
        pools: [Object],
        Connection: [Object],
        types: [Object],
        native: [Getter] },
     pool: 
      Pool {
        _factory: [Object],
        _inUseObjects: [],
        _draining: false,
        _waitingClients: [Object],
        _availableObjects: [],
        _count: 0,
        _removeIdleTimer: null,
        _removeIdleScheduled: false } },
  importCache: {},
  test: 
   { '$trackRunningQueries': false,
     '$runningQueries': 0,
     trackRunningQueries: [Function],
     verifyNoRunningQueries: [Function] } }

I'm quite new to nodejs and very new to PostgreSQL. Hope this is the right place to put the question.

syxolk commented 8 years ago

Your test is not sufficient. Sequelize does not actually connect to the database when you create a Sequelize instance.

Instead try to connect with the psql command:

psql -d euro2016 -h localhost -U euro2016

Or use pgAdmin III (graphical user interface)

Rafnuss commented 8 years ago

Thanks for the help. Ok, I understand what you mean. But I can connect as you suggested, it works. Have you another idea ?

syxolk commented 8 years ago

That's strange. Can you give me your Node.js and PostgreSQL version?

node --version
psql -d euro2016 -h localhost -U euro2016 -c "SELECT version();"
Rafnuss commented 8 years ago

v6.2.0 and PostgreSQL 9.4.8 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.7.2-5) 4.7.2, 64-bit

syxolk commented 8 years ago

Seems reasonable.

I don't do anything special in my code to connect to the database, so it should work regardless whether you connect to the databse in the Node REPL or with node index.js.

Rafnuss commented 8 years ago

ok, no pb. I'll use my own code for this year. Shame, le demo seemed really nice ! Nice work !