Testing a simple HTTP request using nc:

$ printf 'GET / HTTP/1.1\r\nHost: mozilla.org\r\nAccept: */*\r\n\r\n' | nc mozilla.org 80
HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Date: Thu, 10 Mar 2016 23:07:31 GMT
Location: https://www.mozilla.org/
Connection: Keep-Alive
Content-Length: 0

But most hosts result in no output. Using the -v option result is positive:

Connection to stackoverflow.com.com 80 port [tcp/http] succeeded!
Connection to reddit.com 80 port [tcp/http] succeeded!

Using the -D option one line is given:

nc: Permission denied

What is the reason for this?


You may want -q 1 (or 2 or 3 or something) as otherwise nc will exit before the remote server has issued its response.

-D probably requires root.

  • That catches me out every time with nc. – EightBitTony Mar 10 '16 at 23:36

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.