First, verify which PostgreSQL versions are installed:
brew list | grep postgresql
Then, check the location of pg_restore
:
which pg_restore
And confirm the version it is using:
pg_restore --version
If it's still showing PostgreSQL 14, it means your system is not using the newly installed PostgreSQL version.
Find out the installed PostgreSQL versions via:
brew info postgresql
If you recently upgraded, you might have a newer version installed but not linked.
Run:
brew link postgresql
If you see an error about conflicting files, force the link:
brew link --overwrite postgresql
Then, restart your terminal and check pg_restore --version
again.
Homebrew installs newer PostgreSQL versions under /opt/homebrew/bin
(for Apple Silicon) or /usr/local/bin
(for Intel Macs).
List the available versions:
ls /opt/homebrew/Cellar/postgresql/
(or for Intel Macs)
ls /usr/local/Cellar/postgresql/
If a newer version (e.g., 16.x) is installed, but pg_restore
is still using an older one, run:
/opt/homebrew/Cellar/postgresql/16.2/bin/pg_restore --version
(or)
/usr/local/Cellar/postgresql/16.2/bin/pg_restore --version
If this shows the correct version, update your PATH
:
echo 'export PATH="/opt/homebrew/Cellar/postgresql/16.2/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Or for Intel Macs:
echo 'export PATH="/usr/local/Cellar/postgresql/16.2/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Now, check pg_restore --version
again.
If Homebrew isn’t working as expected, manually install PostgreSQL 16:
brew install postgresql@16
brew link postgresql@16 --force
Then check:
pg_restore --version
If you've installed PostgreSQL 16 but it's not active, restart the service:
brew services restart postgresql
Then, verify again:
pg_restore --version
Once pg_restore
shows PostgreSQL 16.x, try running your restore command again.
Let me know if you need more help! 🚀