How to fix homebrew postgreSQL after abrupt shutdown

Aashish Peepra
1 min readFeb 25, 2024


On my Macbook I installed postgreSQL@14 using homebrew. However, I noticed that sometimes abruptly restarting my MacBook crashes the PostgreSQL server.

I tried to find the exact reason behind it, but couldn’t. But here’s a list of steps I follow to re-install it successfully again. Just uninstalling the formula isn’t enough. You need to delete a certain corrupted piece of file as well.

Brew list
Brew uninstall postgresql@14
Cd /
Rm -rf /opt/homebrew/var/postgresql@14
Brew install postgresql@14
Brew services start postgresql@14

Here’s what each command does

Brew uninstall postgresql@14: Uninstall the current existing postgresql@14 formula from your system.

/opt/homebrew/var/postgresql@14: Deletes a corrupted file which isn’t removed automatically when you uninstall the PostgreSQL formula.

Then, you reinstall it and start the service as a background job. I know this sounds pretty straightforward and naive but took me 15 minutes to debug it when it happened for the first time.

Hope it helps!



Aashish Peepra

Software Engineer @commenda-eng | 100K+ people used my websites | Mentored 28K+ Developers globally | Google Solution challenge global finalist