Grails on Heroku, 503, postgres connection refused


I ran through the Grails tutorial for Heroku and ended up with …


Problem accessing /. Reason:

Service Unavailable
Powered by Jetty://

… which totally sucks.

I went through the stages of grief and eventually added some more grails plugins.

I was noticing some exceptions around sessionFactory and webxml and some other autowiring stuff. The problem details escape me but, I added these to the plugins{ …} in BuildConfig.groovy.

compile ":webxml:1.4.1"
compile ":database-session:1.1.2"

compile ':heroku:1.0.1'
compile ':cloud-support:1.0.8'

Then, with the stack trace cleaned up a bit, I noticed:

org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Obviously my connection string is wrong. But…? How…? Why…?

Then finally I gleaned from the Heroku postgres page that maybe my postgres database wasn’t actually what was in DATABASE_URL.

You can find your database by running

heroku addons

If you don’t have one for some reason, you can create one with heroku addons. Just do heroku help addons for details.

Once you know your database name just promote it to get it into the DATABASE_URL environment variable.

heroku pg:promote DATABASE_NAME


As an added bonus, I ignore the transation manager INFO message. Grails has a transaction manager.

more information:

If you enjoyed this post, make sure you subscribe to my RSS feed!

About Eric Holsinger

Eric Holsinger is a mobile app developer and hobbyist photographer. He lives near the coast in Southern Maine with with his wife and son.