Regarding the question Simple command line HTTP server I would like to know, what is the simplest method for creating a http server listening on a specified port that will always cause timeout (it just eats the request and never responds).

I am looking for a dead simple oneliner. It would be useful for the purpose of testing clients.


You can use NetCat to just listen on a port and do nothing:

nc -l $PORT

If it doesn't have to respond, you can use netcat.

nc -lp [port] -w [timeout]

Option -l to use netcat as server, -p for the port and -w for the timeout.

  • -w [timeout] closes the socket, producing a broken pipe exception in the client (e.g. Excon::Errors::SocketError: Broken pipe - Broken pipe (Errno::EPIPE)). It was not exacly my usecase, but it can help someone. – mirelon Feb 16 '15 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.