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

Apple M1芯片下如何修复Homebrew中postgresql@16的服务错误256?

PostgreSQL 16(Homebrew安装,Apple M1)运行异常求助

环境与问题概述

  • 设备:Apple M1(Arm架构)
  • 安装方式:通过Homebrew安装postgresql@16
  • 核心问题:服务状态异常,手动启动失败,但Django可正常连接数据库,psql命令无响应

具体现象

1. Brew服务状态异常

执行brew services list输出:

Name          Status     User   File
postgresql@16 error  256 dmitry ~/Library/LaunchAgents/homebrew.mxcl.postgresql@16.plist

2. 手动启动报错

关闭brew管理的postgresql@16服务后,执行pg_ctl -D /opt/homebrew/var/postgresql@16 start,报错如下:

2024-06-21 17:32:26.356 MSK [3252] LOG:  starting PostgreSQL 16.3 (Homebrew) on aarch64-apple-darwin23.4.0, compiled by Apple clang version 15.0.0 (clang-1500.3.9.4), 64-bit
2024-06-21 17:32:26.356 MSK [3252] LOG:  could not bind IPv6 address "::1": Address already in use
2024-06-21 17:32:26.356 MSK [3252] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2024-06-21 17:32:26.356 MSK [3252] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2024-06-21 17:32:26.356 MSK [3252] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2024-06-21 17:32:26.356 MSK [3252] WARNING:  could not create listen socket for "localhost"
2024-06-21 17:32:26.356 MSK [3252] FATAL:  could not create any TCP/IP sockets
2024-06-21 17:32:26.357 MSK [3252] LOG:  database system is shut down

3. 矛盾现象

  • Django项目可正常连接数据库,创建、读取对象均无问题
  • 在PyCharm终端执行psql postgres后,仅显示postgres-#提示符,无任何响应

已尝试的无效方案

  • 参考Stack Overflow相关解决方案,查找/opt/homebrew/var/postgresql@16目录下的postmaster.pid文件,未找到,现有方案均无法解决问题

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 04:52:34