Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a terminal command or something on OSX that I can use to test if I can reach some ports on a remote server?

I know these ports are reachable on that server, because I can access them from another computer on another network but what I need is a way to test from another computer, if I can reach that ports, in this case 110 and 25 (POP and SMTP), from a specific computer and if possible a trace or something that can be done to see what is causing the blockage.

share|improve this question
up vote 6 down vote accepted

You can see if the server accepts a connection on the port by running telnet HOSTNAME PORT or nc HOSTNAME PORT. If the server is listening, the connection will be established, you'll see the banner sent by the server if any, and you'll be able to type commands. If the server isn't listening or if a firewall is blocking the way, nc or telnet will not be able to initiate the connection and you'll get an error message (except with some overly quiet versions of nc (netcat), I don't know about the one on OSX).

To diagnose a firewall, you can use traceroute -P tcp -p 25 to see how far packets to port 25 get. The last reached host is the one before the firewall.

share|improve this answer

telnet and netcat are our friends. With netcat having the advantage that it works with UDP, too.

share|improve this answer
there is no netcat on OSX. Telnet to port 110? the server is not prepared to accept that. Server is CentOS 6.3. – SpaceDog May 14 '13 at 22:44
@DigitalRobot What is "the server is not prepared to accept that" supposed to mean? It is not possible to make precise connection tests with closed ports. – Hauke Laging May 14 '13 at 22:47
@DigitalRobot Netcat is present, the executable is nc. – Gilles May 14 '13 at 22:49
nope. nc not present. – SpaceDog May 14 '13 at 22:51
I'm seeing several places (mostly other SE sites) where people on OS X are complaining that the version that comes with OS X is old. So I'm willing to bet it's there somewhere or there's an option to install it somewhere. – Bratchley May 14 '13 at 22:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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