Upgrade to 9.0.0-ce.0 from 8.17.3-ce.0 with external postgres

I'm experiencing problems with the database migration whilst using an external postgres process (on the same machine) Postgres version is 9.6.2

gitlab-ce (9.0.0-ce.0) wird eingerichtet ...


       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at https://git.flexibytes.com
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
Checking PostgreSQL executables:Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab::postgresql-bin"]
Synchronizing Cookbooks:
  - package (0.0.0)
  - runit (0.14.2)
  - gitlab (0.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: gitlab::postgresql-bin
  * ruby_block[Link postgresql bin files to the correct version] action run (skipped due to only_if)

Running handlers:
Running handlers complete
Chef Client finished, 0/1 resources updated in 02 seconds
Checking PostgreSQL executables: OK
Checking for an omnibus managed postgresql: NOT OK
No currently installed postgresql in the omnibus instance found.
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install: OK
Upgrading PostgreSQL to 9.6.1
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Toggling deploy page:cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: down: gitaly: 0s, normally up
ok: down: gitlab-monitor: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: mattermost: 1s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: prometheus: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 0s, normally up
Toggling services: OK
There wasn an error fetching locale and encoding information from the database
Please ensure the database is running and functional before running pg-upgrade
STDOUT: /opt/gitlab/bin/gitlab-psql error: could not load /opt/gitlab/etc/gitlab-psql-rc
Either you are not allowed to read the file, or it does not exist yet.
You can generate it with:   sudo gitlab-ctl reconfigure
STDERR: 
Stopping the database: OK
Update the symlinks: OK
Creating temporary data directory: OK
Initializing the new database:Error initializing database for 9.6.1
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.

STDERR: initdb: invalid locale name "--encoding"
== Fatal error ==
Please check the output and try again
== Reverting ==
== Reverted ==
== Reverted to 9.2.18. Please check output for what went wrong ==
Toggling deploy page:rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: run: gitaly: (pid 4152) 1s
ok: run: gitlab-monitor: (pid 4157) 0s
ok: run: logrotate: (pid 4161) 1s
ok: run: mattermost: (pid 4167) 0s
ok: run: node-exporter: (pid 4175) 1s
ok: run: postgres-exporter: (pid 4183) 0s
ok: run: prometheus: (pid 4188) 0s
ok: run: redis-exporter: (pid 4203) 1s
ok: run: sidekiq: (pid 4209) 0s
Toggling services: OK
Ensuring PostgreSQL is updated: NOT OK
Error ensuring PostgreSQL is updated. Please check the logs
dpkg: Fehler beim Bearbeiten des Paketes gitlab-ce (--configure):
 Unterprozess installiertes post-installation-Skript gab den Fehlerwert 1 zurück
Fehler traten auf beim Bearbeiten von:
 gitlab-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)