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

无法连接PostgreSQL服务器问题求助(Homebrew安装环境)

无法连接Homebrew安装的PostgreSQL服务器
  • 此前PostgreSQL服务运行正常,今早突然无法连接;已通过Homebrew卸载重装PostgreSQL@14
  • pgAdmin 4连接报错截图:
    pgAdmin 4连接报错
  • 找不到解决方案中提及的postgresql.conf和pg_hba.conf配置文件,确认PostgreSQL安装路径为/opt/homebrew/Cellar/postgresql@14
  • 尝试相关启动方案时,多数命令返回如下提示:

    WARNING: The locate database (/var/db/locate.database) does not exist.
    To create the database, run the following command:
    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
    Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear.

  • 修改路径尝试启动服务器时,报错:pg_ctl: directory "/opt/homebrew/postgres_db_cluster" does not exist.

编辑1

按PostgreSQL Wiki中Homebrew相关步骤操作后,问题仍存在:

  1. 执行命令:brew services restart postgresql@14,返回:

    ==> Successfully stopped postgresql@14 (label: homebrew.mxcl.postgresql@14)
    ==> Successfully started postgresql@14 (label: homebrew.mxcl.postgresql@14)

  2. 执行psql postgres测试连接,报错:

    psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?


编辑2

尝试相关方案的Update 3第一步,结果如下:

abhinash.kumar@ ~ % pg_ctl -D /usr/local/var/postgres status
pg_ctl: directory "/usr/local/var/postgres" is not a database cluster directory.

同时找不到该方案中提到的pg_hba.conf.sample文件


编辑3

再次尝试通过Homebrew启动服务,执行brew services start postgresql@14报错:

abhinash.kumar@ ~ % brew services start postgresql@14     
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/abhinash.kumar/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist` exited with 5.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 21:15:38