1、设置环境变量

launchctl setenv OLLAMA_HOST "0.0.0.0"

ref:https://github.com/ollama/ollama/blob/main/docs/faq.md

2、重启ollama

3、验证是否能正常访问

curl http://localhost:11434/api/generate -d '{
  "model": "qwen2",
  "prompt": "Why is the sky blue?",
  "options": {
    "num_ctx": 4096
  }
}'