It could be possible that this here doesn’t work against newer PostgreSQL versions anymore:
You could try to modify postgresql_detect.nasl
to replace:
script_require_ports("Services/postgresql", 5432);
by:
script_require_ports("Services/postgresql", "Services/unknown", 5432);
and:
port = unknownservice_get_port(default:5432);
with the following below as a follow-up to see if this is working out for your case.