In my case, Xdebug couldn't connect because the debug client was listening on IPv6 (::9003). Changing it to IPv4 (0.0.0.0:9003) fixed the issue.
::9003
0.0.0.0:9003