PrismarineJS / bedrock-protocol

Minecraft Bedrock protocol library, with authentication and encryption
https://prismarinejs.github.io/minecraft-data/?v=bedrock_1.17.10&d=protocol
MIT License
308 stars 72 forks source link

Failed to bind server on [0.0.0.0]/19132, is the port free? #446

Closed OguzhanUmutlu closed 1 year ago

OguzhanUmutlu commented 1 year ago

I've tried multiple ports, it says this for all of them.

Error:

Failed to bind server on [0.0.0.0]/19132, is the port free?
project_path\node_modules\raknet-native\lib\RakNet.js:86
    return this.server.listen(packets => {
                       ^

TypeError: Server failed to start
    at Server.listen (project_path\node_modules\raknet-native\lib\RakNet.js:86:24)
    at RakNativeServer.listen (project_path\node_modules\bedrock-protocol\src\rak.js:134:17)
    at Server.listen (project_path\node_modules\bedrock-protocol\src\server.js:109:25)
    at file:///project_path/Main.js:12:14
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

My code:

import {createServer} from "bedrock-protocol";

const server = createServer({
    host: "0.0.0.0",
    port: 19132,
    version: "1.20.10",
    motd: {
        motd: "Minecraft Bedrock Server", levelName: "world"
    }
});

await server.listen();

The line that throws the error: https://github.com/extremeheat/node-raknet-native/blob/master/src/RakServer.cpp#L148

OguzhanUmutlu commented 1 year ago
import {Server} from "bedrock-protocol";

const server = new Server({
    host: "0.0.0.0",
    port: 19132,
    version: "1.20.10"
});

await server.listen();

This worked.

extremeheat commented 1 year ago

This error is because the port you want to use, 19132, was not free when you tried to run the program. You can use the netstat command to check what ports are in use.