I was using Postgres universal (postgresql package managed by brew) and I had installed postgresql@14 managed version by brew at the same time. This instruction covers what to do if you use postgresql@14 managed by brew or the universal version.
This instruction is inspired by the issue.
You can change the version to the one that you want to upgrade to. It's recommended to upgrade one version at a time.