# Can't get Postgresql working on Focal

**URL:** <https://travis-ci.community/t/cant-get-postgresql-working-on-focal/13795>\
**Category:** Environments\
**Created:** [May 2, 2023, 6:03pm UTC](https://travis-ci.community/t/cant-get-postgresql-working-on-focal/13795 "2023-05-02T18:03:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![catmando](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/catmando/32/5467_2.png) [@catmando](https://travis-ci.community/u/catmando)\
**Post date:** [May 2, 2023, 6:03pm UTC](https://travis-ci.community/t/cant-get-postgresql-working-on-focal/13795/1 "2023-05-02T18:03:46Z")

</div>

I am trying to upgrade our CI build from Xenial to Focal

I can’t get Postgresql to go.

I have followed different instructions (which seem. bit contradictory)

The latest is this setup:

```auto
dist: focal

env:
  global:
    - PGPORT=5433 # NOTE ADDING THIS MAKES NO DIFFERENCE

addons:
  postgresql: "11"
  apt:
    sources:
      - sourceline: 'deb http://dl.yarnpkg.com/debian/ stable main'
        key_url: 'http://dl.yarnpkg.com/debian/pubkey.gpg'
      - sourceline: 'deb http://dl.google.com/linux/chrome/deb/ stable main'
        key_url: 'https://dl-ssl.google.com/linux/linux_signing_key.pub'
    packages:
      - chromium-chromedriver
      - google-chrome-stable
      - yarn
      - redis-server
      - postgresql-11
      - postgresql-client-11

```

which was recommended elsewhere in a post here.

That fails like this:

```auto
Installing APT Packages

177PostgreSQL package is detected. Stopping postgresql service. See https://github.com/travis-ci/travis-ci/issues/5737 for more information.

178$ sudo systemctl stop postgresql

1790.39s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install chromium-chromedriver google-chrome-stable yarn redis-server postgresql-11 postgresql-client-11

180Reading package lists...

181Building dependency tree...

182Reading state information...

183E: Unable to locate package postgresql-11

184E: Unable to locate package postgresql-client-11

apt-get.diagnostics

185apt-get install failed

284The command "sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install chromium-chromedriver google-chrome-stable yarn redis-server postgresql-11 postgresql-client-11" failed and exited with 100 during .

285

286Your build has been stopped.

```

* * *

Before that I tried a configuration like this:

```auto
env:
  global:
    - PGPORT=5433 # NOTE ADDING THIS MAKES NO DIFFERENCE
services:
  - postgresql

```

which was what the documentation appears to recommend but that errors with:

```auto
3.20s$ travis_setup_postgresql
Starting PostgreSQL v12
Assertion failed on job for postgresql@12-main.service.
sudo systemctl start postgresql@12-main
...
$ psql -c 'create database hyper_mesh_test_db;' -U postgres
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
The command "psql -c 'create database hyper_mesh_test_db;' -U postgres" failed and exited with 2 during .
Your build has been stopped.

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![catmando](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/catmando/32/5467_2.png) [@catmando](https://travis-ci.community/u/catmando)\
**Post date:** [May 4, 2023, 2:44pm UTC](https://travis-ci.community/t/cant-get-postgresql-working-on-focal/13795/2 "2023-05-04T14:44:14Z")

</div>

I found the solution here:

> [@Postgresql broken on Focal](https://travis-ci.community/t/postgresql-broken-on-focal/10371):
>
> It seems to me that something has changed recently (this week) with Postgresql on Focal. My configuration starts with dist: focal language: python python: - "3.8" addons: apt: packages: - yarnpkg postgresql: "12" services: - postgresql - redis-server … before\_script: - psql -c 'CREATE DATABASE fereol\_test;' -U postgres It used to work perfectly well, and suddenly, yesterday, my builds started failing on CREATE DATABASE step with the message: $ psql -c 'CREATE DATABASE…
