What ports are used by the replica locally?

When I dfx start, I get the following output:

...
Dashboard: http://localhost:50383/_/dashboard

So my first assumption was that the replica was being served on :50383, although I was then confused by /_/dashboard. Since /_/dashboard appears nowhere in the spec, I assumed it was some other process that bound on that port to provide extra info. Visiting the address, I see the following:

Http Server Config
Config { listen_addr: 127.0.0.1:0, port_file_path: ... }

which suggests that the replica just binds to 0 and then reports the port it was assigned. Unfortunately for me, if port_file_path was ever written, it was gone by the time I tried reading it.

I then turned to OS tools, and discovered that 4 different ports were bound:

$ sudo lsof -iTCP -sTCP:LISTEN -n -P
...
replica   21209 nicolas   43u  IPv4 0x49f94277d571ae23      0t0  TCP 127.0.0.1:50381 (LISTEN)
replica   21209 nicolas   44u  IPv4 0x49f94277d57197e3      0t0  TCP *:50382 (LISTEN)
replica   21209 nicolas   45u  IPv6 0x49f94277d56a5afb      0t0  TCP *:50383 (LISTEN)
icx-proxy 21211 nicolas    9u  IPv4 0x49f94277d571cf83      0t0  TCP 127.0.0.1:4943 (LISTEN)

It looks like only 50383 is actually the replica, since it’s the only one that actually output some status (as per the spec):

~$ curl 127.0.0.1:50381/api/v2/status
curl: (52) Empty reply from server
~$ curl 127.0.0.1:50382/api/v2/status
curl: (52) Empty reply from server
~$ curl 127.0.0.1:50383/api/v2/status
+��|ic_api_versionf0.18.0hroot_keyX�0��0...

Couple questions:

  • What is this /_/dashboard, and is that served by the replica itself? If so, where (ideally in the spec) can I read more about it?
  • What are the other two “replica” ports 50381 and 50382?
2 Likes

/_/dashboard is a human readable debug endpoint, it’s not part of the spec. It produces an HTML dashboard displaying stuff like the replica version and subnet type; and listing all canisters. There’s also /_/pprof next to it, which allows you to collect replica CPU profiles in real time.

On the same port, as you already discovered, you get the /api endpoints, described in the IC spec.

The other two ports, if I had to guess, are the metrics endpoint (also HTTP, produces replica metrics in the text format accepted by Prometheus); and the P2P endpoint (not HTTP, look in the IC repository under /rs/transport if you’re curious).

2 Likes

FYI, probably the most convenient way of figuring out the replica port (to send api calls to) is to run dfx info replica-port.

3 Likes