# Command psql failed

**URL:** <https://travis-ci.community/t/command-psql-failed/7555>\
**Category:** Deployment\
**Created:** [March 12, 2020, 10:30am UTC](https://travis-ci.community/t/command-psql-failed/7555 "2020-03-12T10:30:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Munoon](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/munoon/32/4023_2.png) [@Munoon](https://travis-ci.community/u/Munoon)\
**Post date:** [March 12, 2020, 10:30am UTC](https://travis-ci.community/t/command-psql-failed/7555/1 "2020-03-12T10:30:25Z")

</div>

I’m trying to set up a postgres database, but when I create it, I get bash error.

Config:

```auto
language: java
jdk: openjdk11

cache:
  directories:
    - $HOME/.m2

before_install:
  - sudo apt-get update
  - sudo apt-get --yes remove postgresql\*
  - sudo apt-get install -y postgresql-11 postgresql-client-11
  - sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
  - sudo service postgresql restart 11

before_script:
  - psql -c 'create database bank' -U postgres
  - psql -c 'create user "user"; grant all privileges on database bank to "user"' -U postgres

services:
  - postgresql

addons:
  postgresql: "11.2"

branches:
  only:
    - master

```

Result:

```auto
$ psql -c 'create database bank' -U postgres
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
The command "psql -c 'create database bank' -U postgres" failed and exited with 2 during .

```

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [March 12, 2020, 2:48pm UTC](https://travis-ci.community/t/command-psql-failed/7555/2 "2020-03-12T14:48:12Z")

</div>

Hey @Munoon,

Instead of having the `addons` section, try doing

```auto
services:
  - postgresql: "11.2"

```

See if that makes any difference.

---

<div class="post-metadata">

**Author:** ![Munoon](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/munoon/32/4023_2.png) [@Munoon](https://travis-ci.community/u/Munoon)\
**Post date:** [March 13, 2020, 9:39am UTC](https://travis-ci.community/t/command-psql-failed/7555/3 "2020-03-13T09:39:24Z")

</div>

Still not working…
