~ → cat testConnection.js var net = require('net'); var url = require('url'); // edit this (password) var conString = 'tcp://crypton_test_user:crypton_test_user_password@localhost:5432/crypton_test'; // default var config = parse(conString); console.log(config); var stream = new net.Stream(); stream.on('connect', function () { console.log('connected', arguments); }); stream.on('data', function () { console.log('data', arguments); }); stream.on('error', function () { console.log('error', arguments); }); stream.on('end', function () { console.log('end', arguments); }); stream.connect(config.port, config.host); // Below is code from the node-postgres module function parse (str) { //unix socket if(str.charAt(0) === '/') { return { host: str }; } // url parse expects spaces encoded as %20 str = encodeURI(str); var result = url.parse(str); var config = {}; config.host = result.hostname; config.database = result.pathname ? result.pathname.slice(1) : null; var auth = (result.auth || ':').split(':'); config.user = auth[0]; config.password = auth[1]; config.port = result.port; return config; }; ~ → node testConnection.js { host: 'localhost', database: 'crypton_test', user: 'crypton_test_user', password: 'crypton_test_user_password', port: '5432' } connected {} ^C%