If you’re using CircleCI’s experimental “Ubuntu 14.04 Trusty” container, you may have already noticed that both Postgres 9.4 and Postgres 9.5 are already running. It’s not officially supported, so without some tweaks, will only be able to access the 9.4 instance. These changes to your circle.yml will force Rails to use the new version.

machine:
  environment:
    # See note about config.database.yml below.
    DATABASE_URL: postgres://postgres@127.0.0.1:5433/test_database
database:
  override:
    # This next line prevents Circle from automatically overwriting
    # config/database.yml with one pointing at Postgres 9.4.
    - true
dependencies:
  override:
    # Just to be 100% certian you are using 9.5, and save a bit of memory.
    - sudo service postgresql stop 9.4

    # The 9.4 instance has been configured to work with Docker. Just
    # copy that over to 9.5 and restart.
    - sudo cp -v /etc/postgresql/9.{4,5}/main/pg_hba.conf && sudo service postgresql restart 9.5

If your Rails project was created before Rails 4.1, you may not yet have changed over to using DATABASE_URL. Your config/database.yml should look like this:

test:
  url: <%= ENV['DATABASE_URL'] %>