MineFlayer bot Error: read ECONNRESET as I was trying to log it in to my server

I was following a tutorial made by this guy: https://www.youtube.com/watch?v=P7TIRIDuGjc

I’ve written the exact code he had written, with only the ‘version’ added on

const mineflayer = require("mineflayer");

var settings = {
    username: 'TestBot',
    host: 'localhost',
    version: '1.21.4'
};

const bot = mineflayer.createBot(settings);

And have also created a localhost server with online-mode=false on Minecraft. I’ve set myself to Op, yet when I run the code node simple-bot.js it returned this error message which frankly I don’t understand, I have a feeling it’s a network issue but how to debug I have no idea.

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

I’ve only just began learning to make Minecraft Bots, and tbh I only have intermediate skills in JS and Node, so when I search up online a lot of the answers are either too complicated or the issues were too different for me to grasp. Please help