Last Updated: February 25, 2016
·
741
· curtis

Make Heroku config variables available during slug compilation

If you've ever run across an error message like this when deploying to Heroku:

could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

Then you know how frustrating it can be... Heroku tells us that it is probably because config variables are being accessed during the precompilation process, but that they are not accessible at that time. They provides some pretty good asset pipeline troubleshooting tips, but they don't always solve the problem.

I just found recently that Heroku Labs has an experimental feature to allow access to Heroku config variables during slug compilation. This has worked really well for me when I couldn't figure out any other way to solve this problem.