# Postgres default port changed from 5432 to 5433

**URL:** <https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347>\
**Category:** Linux\
**Created:** [February 24, 2020, 10:22pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347 "2020-02-24T22:22:03Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ealdent](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ealdent/32/3906_2.png) [@ealdent](https://travis-ci.community/u/ealdent)\
**Post date:** [February 24, 2020, 10:22pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/1 "2020-02-24T22:22:03Z")

</div>

We install the latest postgres 11 using apt-get with a process that has been working smoothly for many months (see below). However, a few hours ago it began failing because the default postgresql.conf suddenly changed from port 5432 to 5433. I confirmed on another linux machine outside of travis that this is not what gets installed normally. Any reason for this stealth change or was it made in error?

```auto
sudo apt-get update -qq
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

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 25, 2020, 2:49am UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/3 "2020-02-25T02:49:19Z")

</div>

Did the apt package versions change?

---

<div class="post-metadata">

**Author:** ![amureki](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amureki/32/3339_2.png) [@amureki](https://travis-ci.community/u/amureki)\
**Post date:** [February 25, 2020, 8:29am UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/4 "2020-02-25T08:29:06Z")

</div>

Experienced the same issue today. Had to change port mapping, so setup looks somewhat like:

```
before_install:
# PostgreSQL 11 + PostGIS is not fully supported by Travis,
# we need copy existing config from PG 9.6, stop running instance and start the new one
# Inspired by https://stackoverflow.com/questions/55161807/travis-ci-not-connecting-to-postgresql-11-2
- sudo apt-get update
- sudo apt-get --yes remove postgresql\*
- sudo apt-get install -y graphviz libxml2-dev libxmlsec1-dev libxmlsec1-openssl rabbitmq-server python3-enchant
- sudo apt-get install -y postgresql-11 postgresql-client-11 postgresql-11-postgis-2.5
- sudo sed -e 's/^port.*/port = 5432/' /etc/postgresql/11/main/postgresql.conf > postgresql.conf
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
- sudo service postgresql restart 11
```

---

<div class="post-metadata">

**Author:** ![michalo](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/michalo/32/3911_2.png) [@michalo](https://travis-ci.community/u/michalo)\
**Post date:** [February 25, 2020, 10:24am UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/5 "2020-02-25T10:24:31Z")

</div>

I had the same issue. Fixed by adding line with sed.

```auto
dist: xenial
group: edge

before_install:
  - sudo apt-get update
  - sudo apt-get --yes remove postgresql\*
  - sudo apt-get install -y postgresql-11 postgresql-client-11
  - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/11/main/postgresql.conf
  - sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
  - sudo service postgresql restart 11

```

---

<div class="post-metadata">

**Author:** ![ealdent](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ealdent/32/3906_2.png) [@ealdent](https://travis-ci.community/u/ealdent)\
**Post date:** [February 25, 2020, 2:30pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/6 "2020-02-25T14:30:54Z")

</div>

> [@BanzaiMan](#):
>
> Did the apt package versions change?

Not sure about anything that may have changed in the apt version but the actual version of postgresql is identical.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 25, 2020, 2:57pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/7 "2020-02-25T14:57:19Z")

</div>

Very well. Can you show relevant build log URLs (one passing, another failing), please?

---

<div class="post-metadata">

**Author:** ![ealdent](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ealdent/32/3906_2.png) [@ealdent](https://travis-ci.community/u/ealdent)\
**Post date:** [February 25, 2020, 3:34pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/8 "2020-02-25T15:34:09Z")

</div>

Yeah, it’s a private build so I can’t link to it, but the only line that changed during the installation process is the one showing the port below (previously it was identical but said 5432). I verified by putting it in debug mode that that postgresql.conf installed now contains 5433 as the default port instead of 5432. A default port of 5432 is what gets installed when I follow this exact same procedure on an ubuntu box external to travis.

### Failing

```auto
selecting default shared_buffers ... 128MB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
    pg_ctlcluster 11 main start
Ver Cluster Port Status Owner Data directory Log file
11 main 5433 down postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
update-alternatives: using /usr/share/postgresql/11/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu11) ...

```

### Passing

```auto
selecting default shared_buffers ... 128MB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
    pg_ctlcluster 11 main start
Ver Cluster Port Status Owner Data directory Log file
11 main 5432 down postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
update-alternatives: using /usr/share/postgresql/11/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu11) ...

```

And then when I try to execute `psql` without specifying a port (because it expects the normal default of 5432):

### Failing

```auto
$ psql -c 'create database my_test;' -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 my_test;' -U postgres" failed and exited with 2 during .

```

### Passing

```auto
$ psql -c 'create database my_test;' -U postgres
CREATE DATABASE

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 25, 2020, 4:07pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/9 "2020-02-25T16:07:58Z")

</div>

I can read the private logs for support purposes. The log excerpts are incomplete and could be misleading. If you do not wish to communicate that here, please email [support@travis-ci.com](mailto:support@travis-ci.com) instead. Thanks.

---

<div class="post-metadata">

**Author:** ![akrherz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akrherz/32/367_2.png) [@akrherz](https://travis-ci.community/u/akrherz)\
**Post date:** [February 25, 2020, 5:05pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/10 "2020-02-25T17:05:17Z")

</div>

My PosgresSQL 11 stopped working today too and I am still debugging what is wrong.

```auto
Feb 25 16:54:50 travis-job-52e8b9bc-0564-4590-a9d7-60388fb379d0 systemd[1]: Starting PostgreSQL Cluster 11-main...
Feb 25 16:54:50 travis-job-52e8b9bc-0564-4590-a9d7-60388fb379d0 postgresql@11-main[6338]: Error: /var/ramfs/postgresql/11/main is not accessible or does not exist
Feb 25 16:54:50 travis-job-52e8b9bc-0564-4590-a9d7-60388fb379d0 systemd[1]: postgresql@11-main.service: Can't open PID file /run/postgresql/11-main.pid (yet?) after start: No such file or directory
Feb 25 16:54:50 travis-job-52e8b9bc-0564-4590-a9d7-60388fb379d0 systemd[1]: postgresql@11-main.service: Failed with result 'protocol'.
Feb 25 16:54:50 travis-job-52e8b9bc-0564-4590-a9d7-60388fb379d0 systemd[1]: Failed to start PostgreSQL Cluster 11-main.

```

Will chime back in if I can figure this out 🙂

---

<div class="post-metadata">

**Author:** ![akrherz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akrherz/32/367_2.png) [@akrherz](https://travis-ci.community/u/akrherz)\
**Post date:** [February 25, 2020, 6:11pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/11 "2020-02-25T18:11:48Z")

</div>

Well, if github would start working, it would help 🙂 The problem appears to be isolated to the 11.7-2 release on bionic, xenial is fine. Will keep after it and hope github starts working again!

---

<div class="post-metadata">

**Author:** ![akrherz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akrherz/32/367_2.png) [@akrherz](https://travis-ci.community/u/akrherz)\
**Post date:** [February 25, 2020, 6:21pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/12 "2020-02-25T18:21:50Z")

</div>

The source of the trouble appears to be [with this travis-ci chef commit](https://github.com/travis-ci/travis-cookbooks/commit/f974e3b22bd0a45573170b1083bd7d932862f317) that sets `data_directory` , a workaround

```auto
sudo sed -i "s/^data_directory.*/data_directory = \'\/var\/lib\/postgresql\/11\/main\/\'/" /etc/postgresql/11/main/postgresql.conf

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 25, 2020, 6:49pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/13 "2020-02-25T18:49:30Z")

</div>

Indeed, we released a new image with PostgreSQL 11 pre-installed.

> **[Ubuntu 18.04 Bionic OS Improvements - Travis CI changelog](https://changelog.travis-ci.com/ubuntu-18-04-bionic-os-improvements-137867)**
>
> A new version of our Ubuntu 18.04 Bionic OS image has been released. 
> Changes and bugfixes:
> 
> Added missing...

---

<div class="post-metadata">

**Author:** ![ealdent](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ealdent/32/3906_2.png) [@ealdent](https://travis-ci.community/u/ealdent)\
**Post date:** [February 25, 2020, 7:19pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/14 "2020-02-25T19:19:07Z")

</div>

> [@BanzaiMan](#):
>
> I can read the private logs for support purposes. The log excerpts are incomplete and could be misleading. If you do not wish to communicate that here, please email [support@travis-ci.com](mailto:support@travis-ci.com) instead. Thanks.

Thanks I did submit one, but it sounds like the issue is the new image changed the default port. I’m guessing that will not be reverted, so I will try to use one of the workarounds others have given.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 25, 2020, 7:31pm UTC](https://travis-ci.community/t/postgres-default-port-changed-from-5432-to-5433/7347/15 "2020-02-25T19:31:15Z")

</div>

Thank you for your update and understanding. We apologize for the unexpected issue here.
