Say I am doing something like this: (bsd variant of nc)

nc -k -l 8080 <fifo | nc 80 >fifo

This works great, I can use the server this is run on as a proxy to reach

However, after performing a curl, it looks like the second nc command exits.

How can I prevent this?

  • What shell are you using?
    – camh
    Commented Jul 15, 2019 at 6:06
  • "This works great" Does it? How? What happens when the server on closes the connection?
    – user313992
    Commented Jul 15, 2019 at 6:11
  • Shell is bash. When the server closes the connection I believe this is what causes the second netcat process to exit. I suppose it would be more correct to say "This works great for a single connection".
    – cat pants
    Commented Jul 15, 2019 at 9:02

1 Answer 1


The answer is to use a while loop like so:

while true
  nc 80 >fifo
done < <(nc -k -l 8080 <fifo)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .