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

Atom php-debug配置docker.for.mac.host.internal时出现Could not bind socket错误求助

Troubleshooting "Could not bind socket" with Atom php-debug + Docker for Mac

Hey there, let's work through this socket binding issue you hit when switching to docker.for.mac.host.internal! Here are some practical steps to fix it:

1. Check for Port Conflicts

The most common culprit is another process hogging the debug port (default is 9000 for Xdebug 2, 9003 for Xdebug 3). Run this in your Mac terminal to check:

# For Xdebug 2 default port
lsof -i :9000
# For Xdebug 3 default port
lsof -i :9003

If you see a process listed, either kill it with kill -9 <PID> or change the debug port in both your Atom php-debug settings and Docker's Xdebug config to an unused port (like 9004).

2. Align Xdebug and php-debug Configs

Double-check your Docker container's Xdebug settings to match Atom:

  • Make sure xdebug.client_host is set to docker.for.mac.host.internal (or docker.for.mac.localhost if you're on an older Docker version)
  • Ensure xdebug.client_port in your Xdebug config exactly matches the "Port" value in Atom's php-debug plugin settings. Mismatched ports will cause connection failures that sometimes manifest as socket binding errors.

3. Fix Atom's php-debug Listening Host

In Atom's php-debug settings, set the Server Host to 0.0.0.0 instead of a specific local IP or localhost. This tells the plugin to listen on all network interfaces, which is necessary for Docker to connect to your Mac using docker.for.mac.host.internal.

4. Eliminate Stale Debug Sessions

Sometimes leftover debug processes can hold the socket open. Try these steps:

  • Fully quit Atom (don't just close the window) and restart it
  • Check if any stray php-debug processes are running with ps aux | grep php-debug and kill them if found
  • Restart your Docker container to ensure no old Xdebug connections are lingering

5. Verify Connectivity from Docker

Test if your container can reach your Mac via the special hostname:

# Run this inside your Docker container
ping docker.for.mac.host.internal

If the ping fails, you might need to update Docker for Mac to the latest version (older versions had issues with this hostname) or switch to host.docker.internal (the newer standard hostname for Docker Desktop).

6. Check Mac Firewall Settings

Your Mac's firewall might be blocking incoming connections from Docker. Temporarily disable it (System Settings > Network > Firewall) to test. If that fixes the issue, add Atom to the list of allowed apps to receive incoming connections.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:15:49