If you get "connection refused" errors:
# Check if PostgreSQL is running
brew services list | grep postgresql
# If not running, start it
brew services start postgresql@17
# Check PostgreSQL logs
# For Apple Silicon Macs:
tail -f /opt/homebrew/var/log/postgresql@17.log
# For Intel Macs:
tail -f /usr/local/var/log/postgresql@17.log
If you get authentication errors:
psql -U postgres
Enter your password when promptedC:\Program Files\PostgreSQL\17\data\pg_hba.conf)If port 5432 is already in use:
macOS:
# Find what's using the port
lsof -i :5432
# Stop the conflicting service or change PostgreSQL port
# Edit postgresql.conf: port = 5433
Windows:
# Find what's using the port
netstat -ano | findstr :5432
# Stop the conflicting process or change PostgreSQL port
# Edit postgresql.conf: port = 5433
If the database already exists and you want to recreate it:
# macOS
dropdb zooly2_local
createdb zooly2_local
# Windows
psql -U postgres -c "DROP DATABASE zooly2_local;"
psql -U postgres -c "CREATE DATABASE zooly2_local;"
If psql or createdb commands are not found:
Add PostgreSQL to PATH:
C:\Program Files\PostgreSQL\17\bin to PATHOr use full paths:
& "C:\Program Files\PostgreSQL\17\bin\psql.exe" -U postgres
If you need to set a password for the postgres user on macOS:
# Connect to PostgreSQL
psql -U postgres
# Set password
ALTER USER postgres WITH PASSWORD 'password';
# Exit
\q
Check if PostgreSQL is running:
pg_ctl -D /opt/homebrew/var/postgresql@17 status
Start PostgreSQL manually (if needed):
pg_ctl -D '/opt/homebrew/var/postgresql@17' -l logfile start
Note: The data directory path may vary. For Homebrew on Apple Silicon Macs, it's typically /opt/homebrew/var/postgresql@17. For Intel Macs, it's usually /usr/local/var/postgresql@17.