
Member-only story
Debugging PostgreSQL Installation on macOS
psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory. If you’re a PostgreSQL user, you’ve likely encountered errors like:
If you’re a PostgreSQL user, you’ve likely encountered errors like:
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
But what causes these issues? Before diving into troubleshooting, let’s understand what happens during a PostgreSQL installation on macOS using Homebrew.
Understanding PostgreSQL Installation on macOS
When installed via Homebrew, PostgreSQL follows a structured setup process:
- Installation: Homebrew installs PostgreSQL binaries, configuration files, and necessary dependencies.
- Service Management: Homebrew services allow PostgreSQL to run in the background.
- Data Directory Initialization: PostgreSQL requires an initialized data directory to store databases and settings.
- User and Role Setup: PostgreSQL creates a default user and role system for database management.
What Happens Before and After Installation?
Before Installation
- Ensure Homebrew is installed (
brew -v
to check). - Check for existing PostgreSQL installations:
brew list | grep postgresql
- Remove conflicting versions if necessary:
brew uninstall postgresql@<version>
Installation Process
To install PostgreSQL via Homebrew, run:
brew install postgresql@15
After installation, check the service status:
brew services list
To start PostgreSQL:
brew services start postgresql@15
Using Nix
- Install PostgreSQL via Nix and Start PostgreSQL manually: