↑ ↓ select, Enter open, Esc close

Test if a TCP port is reachable without telnet or nc

Adjust the values, the command updates live
user@server
timeout 3 bash -c '</dev/tcp/db.example.com/3306' && echo offen || echo "geschlossen oder gefiltert"

Uses the Bash built-in /dev/tcp to open a TCP connection without needing telnet or nc installed. If the connection is established within three seconds, offen (German for open) is printed. Useful for checking firewall rules between servers.

Note: This only works in Bash, not in sh or dash. UDP ports cannot be tested reliably this way.

Also searched as

  • test if port is open without telnet
  • check remote port bash dev tcp
  • test firewall rule between servers

Related one-liners

All in Network

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.