Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In my node application i am connecting to a postgres sql in remote system

I have the following connection code:

var sequelize = new Sequelize('postgres://username:[email protected]:5432/dbname');

Its working fine.. but the following connection is not working:

// initialize database connection
var sequelize = new Sequelize(
config.dbname,
config.username,
config.password, {
    dialect: 'postgres',
    port:'5432'------------------->specified port here..
});

My config file:

{
    "server": {
        "port":        3000,
        "forks":        1,
        "siteUrl":      "http://xxx.xxx.xx.xxx:3000"
    },
    "dbpostgres": {
        "host":         "xxx.xx.xx.xx",        
        "username":     "username",
        "port"     :     5432,
        "password":     "password",        
        "dbname":       "dbname"
        }

I am receiving the following error:

"Error: connect ECONNREFUSED","    at errnoException (net.js:770:11)","  

Please help me to solve this..Thanks in advance.....

}

share|improve this question
    
Set the port configuration: var sequelize =new Sequelize(..., {port: config.port, dialect: 'postgres'} . Doesn't this work? –  bnuhero Mar 19 '14 at 5:21
    
Thanks @bnuhero ..I tried that also but the same error. see my edited post.. –  Subburaj Mar 19 '14 at 5:26
    
I'm not sure whether the port should be an integer. So try this: port: 5432 –  bnuhero Mar 19 '14 at 5:32
    
I tried that also..no cange.. –  Subburaj Mar 19 '14 at 5:33
    
Is your database deployed on Heroku? If yes, add protocol: null to the configuration. FYI: options –  bnuhero Mar 19 '14 at 5:50

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.