netcat

Server ports

Check if a server port is accessible. Could be blocked by any of:

  • Local workstation
  • Local network router
  • VPN or proxy
  • DNS Resolver
  • Internet service provider (ISP) (e.g. Verizon)
  • Web application firewall (WAF) (e.g. Sucuri)
  • Content delivery network (CDN) (e.g. Cloudflare)
  • Web server

Attempt to connect to port 21 on a domain but timeout after 15 seconds if no response (-z check without sending data, -v verbose, -w timeout)
netcat -vzw 15 domain.com 21

Credit https://www.inmotionhosting.com

Local ports

Local port 8080 is free if output is 1
sudo nc localhost 8080 < /dev/null; echo $?