Minecraft ERRCONNECT MINEFLAYER ERROR Error: connect ECONNREFUSED ::1:25595

397 Views Asked by At

I am Recieving this errror when i run this simple code snippet

import mineflayer from 'mineflayer';

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25595,
  username: 'Maaz_Bot', // minecraft username
  password:''
})

I was expecting it to join the localhost server which is hosted at port 25595 by using lan world and mineflayer library

2

There are 2 best solutions below

1
Joche Ramirez On

Try importing mineflayer like below and also you can handle the events using, on login and on error

const mineflayer = require('mineflayer');

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25595,
  username: 'Maaz_Bot', // minecraft username
  password: '',
});

bot.on('login', () => {
  console.log('Bot has logged in');
});

bot.on('error', (err) => {
  console.error('Error:', err);
});

For more info please go through documentation

https://www.npmjs.com/package/mineflayer

0
Ammu Bhai On

Try using new port , By quitting the world an rejoining the world again