# Unable to create Repo Database during testing

**URL:** <https://travis-ci.community/t/unable-to-create-repo-database-during-testing/4401>\
**Category:** Elixir\
**Tags:** test\
**Created:** [July 26, 2019, 12:19pm UTC](https://travis-ci.community/t/unable-to-create-repo-database-during-testing/4401 "2019-07-26T12:19:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spkane31](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@spkane31](https://travis-ci.community/u/spkane31)\
**Post date:** [July 26, 2019, 12:19pm UTC](https://travis-ci.community/t/unable-to-create-repo-database-during-testing/4401/1 "2019-07-26T12:19:26Z")

</div>

I am trying to build a CI/CD and testing pipeline for my Elixir/Phoenix application. I’m running Elixir 1.8.2 atop Erlang 21.0 (Erlang 20.0 works too), with postgresql 10.9 for my database. I am currently failing all of my tests because the Travis server is not able to create the database. The error I get is below, and has to do with a failed database connection but I haven’t found anything related to why it is. Is this a postgresql error or have I not configured my travis.yml file correctly? [Here](https://github.com/spkane31/rankings) is a link to my repository hosted on github. Thank you for your help!

```auto
Generated rankings app
** (Mix) The database for Rankings.Repo couldn't be created: killed
11:48:00.674 [error] GenServer #PID<0.3004.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
    (db_connection) lib/db_connection/connection.ex:84: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
The command "mix ecto.create" exited with 1.

```

```auto
language: elixir

elixir:
  - 1.8.2

addons:
  postgresql: '10.9'

service:
  - postgresql

before script:
  - psql -c 'create database rankings_test;' -U postgres
  # - cp config/test.exs config/travis.exs

script:
  - mix deps.get --only test
  - mix ecto.create
  - mix ecto.migrate
  - mix test

```

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [July 26, 2019, 2:18pm UTC](https://travis-ci.community/t/unable-to-create-repo-database-during-testing/4401/2 "2019-07-26T14:18:06Z")

</div>

Possible duplicate of

> [@Postgresql 11.2: Cannot connect](https://travis-ci.community/t/postgresql-11-2-cannot-connect/2680/2):
>
> Without looking into too much details yet, it appears to me that the package is found and configured to run on the next-available port, 5433: [https://travis-ci.org/keithpitty/kpdotcom/builds/507439479#L231](https://travis-ci.org/keithpitty/kpdotcom/builds/507439479#L231). I would imagine that your psql by default will connect to port 5432, but nothing is listening on that port.

---

<div class="post-metadata">

**Author:** ![spkane31](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@spkane31](https://travis-ci.community/u/spkane31)\
**Post date:** [July 27, 2019, 12:00pm UTC](https://travis-ci.community/t/unable-to-create-repo-database-during-testing/4401/3 "2019-07-27T12:00:35Z")

</div>

@native-api  
Yes it was. I had to add the database.yml file and use postgresql-11 on the travis side. Thank you for pointing me to that!
