Error: null; expected '', but found BlockMappingStart; in 'reader'

I have been getting this error while starting cassandra after the initial installation. The issue is with cassandra.yaml in the conf directory tarball installation. In packaged installation, it will be in /etc/cassandra/conf.

This is how the error looks like.

INFO  16:29:46 Configuration location: file:/home/cassandra/apache-cassandra-3.7/conf/cassandra.yaml
Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: Invalid yaml: file:/home/cassandra/apache-cassandra-3.7/conf/cassandra.yaml
 Error: null; expected '<document start>', but found BlockMappingStart;  in 'reader', line 28, column 1:
    num_tokens: 256
    ^
Invalid yaml: file:/home/cassandra/apache-cassandra-3.7/conf/cassandra.yaml
 Error: null; expected '<document start>', but found BlockMappingStart;  in 'reader', line 28, column 1:
    num_tokens: 256
    ^
ERROR 16:29:46 Exception encountered during startup: Invalid yaml: file:/home/cassandra/apache-cassandra-3.7/conf/cassandra.yaml
 Error: null; expected '<document start>', but found BlockMappingStart;  in 'reader', line 28, column 1:
    num_tokens: 256

Reason is that Cassandra is very finiky of spaces provided between key: value. Any violation of this will give "Invalid yaml" error. So, strictly follow the format provided in cassandra.yaml file. Some of the references are below.

Comments