Troubleshooting

Common issues and solutions for PostgreSQL setup

Troubleshooting

Connection Refused (macOS)

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

Authentication Failed (Windows)

If you get authentication errors:

  1. Check the password you set during installation
  2. Try connecting with psql:
    psql -U postgres
    Enter your password when prompted
  3. Verify pg_hba.conf settings (usually at C:\Program Files\PostgreSQL\17\data\pg_hba.conf)

Port Already in Use

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

Database Already Exists

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;"

PATH Issues (Windows)

If psql or createdb commands are not found:

  1. Add PostgreSQL to PATH:

    • Open System Properties → Environment Variables
    • Add C:\Program Files\PostgreSQL\17\bin to PATH
    • Restart your terminal
  2. Or use full paths:

    & "C:\Program Files\PostgreSQL\17\bin\psql.exe" -U postgres

Setting Up Postgres User Password (macOS)

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

Checking PostgreSQL Status (macOS)

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