I'm trying to build a simple multiplayer game. I have a client project and a server project. In the server project I set up an enet server like this:

extends Node

var network = NetworkedMultiplayerENet.new()

var port : int = 29995
var max_players : int = 100

func _ready():
	StartServer()

func StartServer():
	network.create_server(port, max_players)
	get_tree().set_network_peer(network)
	print("Server started")
	
	network.connect("peer_connected", self, "_peer_connected")
	network.connect("peer_disconnected", self, "_peer_disconnected")

This works fine if I try to run it on my local (windows) machine. However, when I try to run it on a virtual ubuntu server I get the following output:

Godot Engine v3.3.stable.official - https://godotengine.org
 
ERROR: create_server: Couldn't create an ENet multiplayer server.
   At: modules/enet/networked_multiplayer_enet.cpp:108.
ERROR: set_network_peer: Supplied NetworkedMultiplayerPeer must be connecting or connected.
   At: core/io/multiplayer_api.cpp:147.

The steps I used to run this:

  1. Exported the .pck file using Linux/X11 settings on windows
  2. Moved .pck file to server
  3. Renamed headless server binary to match the .pck file
  4. Executed binary

I did make sure that my port is allowing inbound and outbound connections with ufw. If the port is free, what could other reasons for this error be?

  1. I looked into the source; it seems that this error occurs if Godot can't allocate memory for some internel enet related objects for some reason.
  2. I have no idea why, but restarting my VPS seems to have fixed it.
2 years later