← Mac Change Notes

Why lsof Shows Hostnames Instead of IP Addresses

On a Mac, add -n to lsof to show numeric IP addresses instead of resolved hostnames. Add -P to keep ports numeric too: lsof -nP -iTCP. A resolved name is a lookup result, not proof of the website requested.

In this article

Keep addresses and ports numeric first

Open Terminal and run the command above to inspect visible TCP sockets. It reads current socket information; it does not change a connection or recover earlier traffic.

For one process, find its current PID in Activity Monitor and replace 12345 in this example:

lsof -nP -a -p 12345 -iTCP

The lowercase -n controls address-to-name conversion. The uppercase -P controls port-number-to-service-name conversion. The -a combines the process and socket selection conditions. Capitalization matters.

The upstream lsof manual documents these options. Your installed man lsof is the reference for the version supplied with your Mac; do not assume every option newly added upstream exists locally.

If your original question is which app is transferring data, start with our Mac app network-connections workflow. This article addresses the narrower question of what a displayed name does—and does not—tell you once you have a connection row.

Separate three different kinds of names

A connection can involve several names that happen to appear near one another:

Name or valueWhat it describes
The numeric peer address in a socket rowThe network endpoint visible to that socket inspection
A hostname displayed for that addressA name supplied by address-to-name resolution
The host in an HTTP requestThe application’s target name for that request

Those values do not form a reliable one-to-one mapping. A server can handle requests for multiple hostnames, and a name lookup can return infrastructure-oriented naming rather than the public name you typed.

For DNS specifically, RFC 1035 defines the IPv4 reverse-lookup domain and PTR records used to associate addresses with domain names. A PTR answer is a DNS record. It is not a transcript of the request that opened a socket.

Also avoid assuming that every name shown locally came from public reverse DNS. The Mac’s naming configuration can resolve local addresses too. Our test below uses loopback deliberately, so its localhost result should not be presented as a test of an external provider’s PTR records.

What our two-name test showed

On November 11, 2026, we created a small HTTP server bound only to 127.0.0.1 on macOS 15.7.5, Apple Silicon. We used the Mac’s lsof 4.91 to inspect two temporary curl processes while their connections remained open.

One curl request used alpha.example.test; the other used beta.example.test. Both used curl’s --resolve option to reach the same local server. This was a deliberate, per-command address substitution, with no edits to the Mac’s hosts file or DNS settings. The curl project’s explanation of name-resolution controls documents that mechanism.

The server recorded only the synthetic requests’ Host fields. We compared those fields with two forms of lsof output:

ObservationFirst requestSecond request
Requested hostalpha.example.testbeta.example.test
Peer shown with lsof -Plocalhost:61422localhost:61422
Peer shown with lsof -nP127.0.0.1:61422127.0.0.1:61422

The clients had different local ports. The table deliberately shows only the peer portion, so it does not imply that the two complete connection tuples were identical.

Neither display mode reproduced the requested hostname. Adding -n changed the address representation, while both requests still reached the same listener. All traffic in this test stayed on the Mac.

This is a small demonstration of the evidence boundary, not a simulation of every browser, proxy or public hosting arrangement. Because we supplied the address explicitly, the experiment does not measure DNS lookup correctness or performance. It shows why the socket endpoint alone cannot identify which of two request names was used.

Why a website name needs other evidence

HTTP carries target information separately from the IP connection. RFC 9110’s Host and authority section describes how that information allows a server to distinguish requests for multiple hostnames.

For a website you are debugging, the browser’s developer tools can show the request URL. For software you maintain, appropriately scoped application or server logs may establish the requested host. Compare evidence from the same request and time rather than inferring a page from an address label.

This does not make lsof a content viewer. A row does not reveal the URL path, submitted form data or encrypted response body. Even seeing port 443 is a separate observation from proving how a particular connection is protected; see our guide to port 443 and encryption.

A reverse lookup may help identify hosting infrastructure, but a mismatch with the website name is not by itself evidence of redirection, compromise or a dishonest app. Equally, a familiar-looking name is not proof that a connection is trustworthy.

Compare like with like when investigating a mismatch

Use this small checklist before drawing a conclusion:

  1. Record the process PID and observation time.
  2. Keep address and port numbers numeric with -nP.
  3. Separate the local endpoint from the peer endpoint on an established row.
  4. Record whether a name came from lsof, a DNS lookup, an app log or a request URL.
  5. Check whether you are observing the same live request and process.

A second command can capture a different moment. Short-lived connections may close between samples, and applications can open new ones. A changed row therefore does not automatically mean that adding -n changed the destination.

A listening row also answers a different question from an established connection. If you are narrowing a result to a port, our lsof port-filter guide explains why a match can include either endpoint and how to select listeners.

When no row appears, record that limitation rather than turning it into a claim that the app never connects. Process lifetime, selection filters and visibility affect what is observable. Start with the numeric endpoint, then add only the identity claims that your independent evidence supports.