Error while sending logs to logstash with filebeats

Getting following error while I try to fetch logs using filebeats to logstash

[logstash.outputs.elasticsearch] Installing elasticsearch template to _template/logstash
[2019-11-13T13:36:49,899][ERROR][logstash.outputs.elasticsearch] Failed to install template. {:message=>"Got response code '400' contacting Elasticsearch at URL 'http://localhost:9200/_template/logstash'", :class=>"LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError",

my filebeat config file

type: log
enabled: true
paths: /home/xxxxx/Desktop/*.log

logstash file

input {
beats {
port => 5044
}
}

filter {
#If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
if [message] =~ "\tat" {
grok {
match => ["message", "^(\tat)"]
add_tag => ["stacktrace"]
}
}

}

output {

stdout {
codec => rubydebug
}
elasticsearch {
hosts => ["localhost:9200"]
}
}