I´m trying to upgrade my server to 10.5.1 and I´m following the steps on url . Everytime I´m getting an error on Step 8
"Choose to Continue Portal Upgrade. .....Specify the user name, password, email, and identity question and answer of the initial administrator account. ...."

or sometimes

Here I´m running a federate/hosted server + Portal and Datastore on Linux (single machine).
I ran portaldiag to check and here the result.
Portal for ArcGIS 10.5.1 Diagnostic Tool
Hostname: smart.....oa.pt
========================================================================
DIAG000: Check for installation as root [PASSED]
DIAG001: Check for 64-bit architecture [PASSED]
DIAG002: Check OS version [PASSED]
DIAG003: Check hostname for invalid characters [PASSED]
DIAG005: Check system limits [PASSED]
DIAG004: Check installed packages [PASSED]
DIAG016: Check Portal for ArcGIS ports [PASSED]
DIAG024: Check localhost resolution [PASSED]
DIAG029: Check file system type [PASSED]
DIAG020: Check hostname IP address mismatches [PASSED]
DIAG026: Check processes of Portal for ArcGIS core services [PASSED]
DIAG028: Check data directory [PASSED]
------------------------------------------------------------------------
There were 0 failure(s) and 0 warning(s) found:
Portal Log:
<Msg time="2017-10-16T12:26:22,906" type="SEVERE" code="209024" source="Portal Admin" process="27847" thread="12" methodName="" machine="smart.....oa.pt" user="" elapsed="">The process of creating a new site failed. Reverting site creation. Migration failed. Index Service configuration failed.</Msg>
<Msg time="2017-10-16T12:27:26,38" type="VERBOSE" code="217063" source="Portal" process="27764" thread="1" methodName="" machine="smart.....oa.pt" user="" elapsed="">The process monitor did not find the connection to the configuration store. The site may not have been initialized. After the site is initialized, the check for database processes will be reattempted.</Msg>
Database log:
LOG: database system was shut down at 2017-10-16 04:25:49 PDT
...
LOG: connection received: host=xyz port=58282
LOG: connection authorized: user=xyz database=xyz
LOG: disconnection: session time: 0:00:00.010 user=xyz database=xyz host=xyz port=5xxx
LOG: received fast shutdown request
LOG: aborting any active transactions
FATAL: terminating connection due to administrator command
LOG: disconnection: session time: 0:00:00.314 user=xyz database=xyz host=xyz port=5xxx
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down