Connection refused on heroku postgresql db via node

I'm running a postgresql database on heroku, via node. I have my server setup to post to '/submit', which calls a database controller to insert the data into the database. Everything works successfully locally, but when I deploy it to heroku and POST, I get the following error in my heroku logs.

2013-01-21T20:23:43+00:00 heroku[router]: at=info method=POST path=/submit host=[MYDOMAIN].herokuapp.com fwd=[IP] dyno=web.1 queue=0 wait=5ms connect=17ms service=35ms status=200 bytes=2
2013-01-21T20:23:46+00:00 app[web.1]:               ^
2013-01-21T20:23:46+00:00 app[web.1]: node.js:201
2013-01-21T20:23:46+00:00 app[web.1]:         throw e; // process.nextTick error, or 'error' event on first tick
2013-01-21T20:23:46+00:00 app[web.1]: 
2013-01-21T20:23:46+00:00 app[web.1]:     at Object.afterConnect [as oncomplete] (net.js:637:18)
2013-01-21T20:23:46+00:00 app[web.1]: Error: connect ECONNREFUSED
2013-01-21T20:23:46+00:00 app[web.1]:     at errnoException (net.js:646:11)
2013-01-21T20:23:48+00:00 heroku[web.1]: Process exited with status 1

and a 503 in the application.

Here's the relevant controller code (in coffeescript).

LOCAL_DB = "postgres://localhost:#{DBNAME}"

connect = ->
    db = process.env.DATABASE_URL or LOCAL_DB
    client = new pg.Client
    client.connect()
    client

insert = (options) ->
    client = connect()
    query = client.query "INSERT INTO #{TABLE} VALUES($1, $2, $3, $4);",
        [options.uid, options.ls_pref, options.hp_pref, options.date]
    query.on "error", onError
    query.on "end", -> client.end()

I did promote my database to DATABASE_URL:

$ heroku config | grep DATABASE_URL
> DATABASE_URL: postgres://[URL]

Why is my connection being refused?

It turns out I wasn't passing the database string when creating the client.

# Yes
db = process.env.DATABASE_URL or LOCAL_DB
client = new pg.Client db
client.connect()

# No
db = process.env.DATABASE_URL or LOCAL_DB
client = new pg.Client
client.connect db

The local database was working despite this rather obvious oversight. You've been warned!