Error: getaddrinfo ENOTFOUND undefined undefined:5432
See original GitHub issuevar express = require('express');
var pg = require('pg');
var CONSTANT = require('../src/constant.js');
var router = express.Router();
var connectionString = CONSTANT.DB_NAME+'://'+CONSTANT.DB_USERNAME+':'+CONSTANT.DB_PASSWORD+'@'+CONSTANT.DB_URL+':'+CONSTANT.DB_PORT+'/'+CONSTANT.DB_SCHEMA;
var client = new pg.Client(connectionString);
client.connect();
var config = {
user: CONSTANT.DB_USERNAME,
database: CONSTANT.DB_SCHEMA,
host: CONSTANT.DB_HOST,
password: process.env.PGPASSWORD,
port: CONSTANT.DB_PORT
};
console.log("config : "+JSON.stringify(config));
var pool = new pg.Pool(config);
pool.on('error', function(error, client) {
if(err) {
console.log(err);
}
})
router.get('/testing', function(req, res, next) {
console.log("--------------");
})
module.exports = router;
Below is the error am getting
events.js:141
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND undefined undefined:5432
at errnoException (dns.js:27:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:26)
Also this link https://github.com/brianc/node-postgres doesn’t seem to be passing the host/hostname to the config param NodeJS version is 4.4.2… PostgreSQL version is 9.5.2
Looking at the error message undefined:5432 it looks like it is not finding the DB host name.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
NodeJS Postgres error getaddrinfo ENOTFOUND
The database name is people and it's running on port 8080 but in this error it's showing 5432 even if I declare the...
Read more >Your server encountered an error (getaddrinfo ENOTFOUND ...
I'm expecting to be able to visual my data. Actual behavior. I setup forest admin with docker (the website gave me the command...
Read more >ConnectionError: getaddrinfo ENOTFOUND postgres - Support
What is the problem? Be very detailed. I'm trying to use a local database and Nginx . I'm removing these services in my...
Read more >Newbie - Trouble connecting to a hosted PostgreSQL database
I'm using ElephantSQL as my host (which uses Amazon's EC2) for my online database. When I make a call in my API, Node...
Read more >Error: getaddrinfo ENOTFOUND postgres docker
If you try to run your JSON server and see this error message “getaddrinfo ENOTFOUND localhost,” it's happening because Webpack cannot find your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @brianc… I deleted my
node_modules
and didnpm install
again. After that am not getting that error. Assuming its resolved?Just wanted to confirm with you before I close this thread.
try this
That should work if you’re using
pg>=6.0.0