I painfully experienced behaviour that I can't seem to find documented here so I wanted to save everyone from repeating my mistake by giving the following heads up:
When starting php -S on a mac (in my case macOS Sierra) to host a local server, I had trouble with connecting from legacy Java.
As it turned out, if you started the php server with
"php -S localhost:80"
the server will be started with ipv6 support only!
To access it via ipv4, you need to change the start up command like so:
"php -S 127.0.0.1:80"
which starts server in ipv4 mode only.