You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS Sierra下brew安装的PostgreSQL启动失败求助

Troubleshooting PostgreSQL Startup Failures on macOS Sierra (Brew Install)

Let’s work through this issue step by step—this is a common hiccup with PostgreSQL on macOS, so we’ll get your server up and running in no time.

First: Fix the "Permission denied" for logfile

Your initial error waiting for server to start..../bin/sh: logfile: Permission denied happens because you’re using a relative path (logfile) for the log, and PostgreSQL can’t write to your current working directory.

The quick fix is to specify an absolute path to a location you own (like your PostgreSQL data directory, which you already have permissions for):

pg_ctl -D /Users/tmo/PSQL-data -l /Users/tmo/PSQL-data/postgres.log start

This tells PostgreSQL to create the log file directly inside your data folder, where it has full access to write.

Next: Diagnose the truncated "waiting for server to s..." output

After restarting, the truncated output means the server is trying to start but getting stuck somewhere. The key to figuring out why is checking the log file you just configured. Run this to see the full error details:

cat /Users/tmo/PSQL-data/postgres.log

The log will show specific issues—here are the most common culprits and their fixes:

1. Data directory permissions are incorrect

PostgreSQL needs full read/write access to its data folder. Verify the permissions first:

ls -ld /Users/tmo/PSQL-data

You should see your username (tmo) listed as the owner. If not, fix the ownership and permissions with:

sudo chown -R tmo:staff /Users/tmo/PSQL-data
sudo chmod -R 700 /Users/tmo/PSQL-data

2. Port 5432 is already in use

PostgreSQL defaults to port 5432. Check if another process is using it:

lsof -i :5432

If you see a process listed, kill it with kill <PID> (replace <PID> with the process ID from the output), or edit your postgresql.conf file in /Users/tmo/PSQL-data to use a different port (look for the port parameter).

3. Use Brew’s built-in commands (simpler alternative)

Since you installed PostgreSQL via Brew, you can let Brew handle the startup details automatically—this avoids manual path and permission headaches:

brew services start postgresql

Check the status with:

brew services status postgresql

If it fails, Brew will log errors to a standard location (usually ~/Library/Logs/Homebrew/postgresql.log for newer setups, or /usr/local/var/log/postgres.log for older ones).

Final Tip

Always start with the log file—it’s PostgreSQL’s way of telling you exactly what’s broken. If the above steps don’t resolve the issue, sharing the full log content will help narrow down the problem further!

内容的提问来源于stack exchange,提问作者BetterOffAlone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:12:24