Stop reaching for nc to check a remote port

Networking & Firewall (Ss/Netstat/Iptables/Nftables/Curl)

Stop reaching for nc to check a remote port

🧩 The Challenge

A new database server is supposed to be up, or an API endpoint you need to hit. But connections just hang or error out. Is it the server firewall? Your network? Is the service even running? You’re on some minimal box, no netcat or telnet installed, and you need a quick diagnostic.

💡 The Fix

Most Linux systems have curl pre-installed, and it’s way more versatile than you think for quick port checks. You can tell it to just try connecting to a raw TCP port, skipping any HTTP stuff entirely, and get a fast answer.

curl -v telnet://db-server-01.example.com:5432
# Or for an HTTP/S port, you can just try this and watch the output
curl -v --connect-timeout 5 https://api.somecorp.com:443

⚙️ Why It Works

The telnet:// pseudo-protocol tells curl to simply try to initiate a raw TCP connection to the specified host and port. It’ll show you if it connects, if it times out, or if DNS failed, without trying to speak HTTP. And for standard HTTP/S endpoints, the –connect-timeout flag helps quickly confirm if the TCP handshake even completes before curl expects a full application response.

🚀 Pro-Tip: Pair this with a watch command when you’re waiting for a service to come up.

Linux Tips & Tricks | © ngelinux.com | 11/3/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted