When running netcat in the background from a script, any attempt to connect will kill it.
nc -l 1337 &
When you run this, and then run:
nc localhost 1337
The original instance dies immediately, with no indication for why. However, if we do:
tail -f /dev/null | nc -l 1337 &
Then connecting to port 1337 will work correctly, and you can see the output being echoed on the terminal.