Failed to refresh session cache: ShardingStateNotInitialized: Cannot accept sharding commands if sharding state has not been initialized with a shardIdentity document

Hello,

Have you started your shard replica set using the correct configuration ?

The guide that you linked to shows that sharding.clusterRole option to be put on shardsvr , either by establising correct configuration file:

sharding:
    clusterRole: shardsvr
replication:
    replSetName: <replSetName>
net:
    bindIp: localhost,<ip address>

Or by starting mongod from command line (also using correct configuration):
mongod --shardsvr --replSet <replSetname> --dbpath <path> --bind_ip localhost,<hostname(s)|ip address(es)>

Kind regards, Tin.