sstabeloader in apache cassandra 4.0 is using 9042 transport port even after overriding it with the "-p" option

Solution 1:

Cassandra folks changed sstableloader heavily in 4.0.

Currently it parses both -p and -sp options (native and storage ports), but doesn't use them as documented and expected.

  1. Native port (-p option) is simply ignored. The way to pass the custom port is -d host1:native_port1,host2:native_port2,.... So, your command should look like
sstableloader -d 10.14.20.148:9942 ...

My guess is that they try to unify the endpoint format across all client tools.

  1. Storage port (-sp option) is a longer story. On startup sstableloader connects to the given Cassandra cluster, takes its broadcast address and storage port and uses them. Only if Cassandra cluster has no broadcast_address in its configuration file ($CASSANDRA_HOME/conf/cassandra.yaml), sstableloader defaults to the storage port, passed as an option. See details in CASSANDRA-14522.