I am having issues with setting up the sequelize module for node.js.

First I set up a username and password in postgresql:

postgres=# CREATE USER testuser WITH PASSWORD 'test';

Here is my initialize code:

var Sequelize = require('sequelize');
var sequelize = new Sequelize('testdb', 'testuser', 'test', {
    host: 'localhost',
    port: 5342,
    dialect: 'postgres'
});

sequelize.query('select * from mytbl').success(function(tbl){
    console.log('success');
});

However, when i run this short bit of code I get the following error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Failed to authenticate for PostgresSQL. Please double check your settings.

I am not sure what I am doing wrong? If anyone can help it would be greatly appreciated. Thanks!

share
    
What's in Postgres' log? – Milen A. Radev Dec 20 '13 at 12:46
    
The logs in /var/log/postgresql/postgresql-9-1-main.log doesn't seem to have anything in it at all related to the sequelize code – mathmonkey Dec 20 '13 at 13:13
1  
Try to connect to Postgres with the CLI client psql using the same connection info, e.g. psql -h localhost -U testuser testdb. – Milen A. Radev Dec 20 '13 at 13:18
    
Hmm it looks like everything works fine when I connect in that way – mathmonkey Dec 20 '13 at 13:32
1  
@mathmonkey what happens if you try like this: sequelize = new Sequelize('postgres://testuser:test@localhost:5432/testdb', { dialect: 'postgres', protocol: 'postgres' }) – MikeSmithDev Dec 20 '13 at 13:50

This example worked when I changed the port to 5432.

share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.