• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Linux Server crash with System.NullReferenceException


Hello, I'm trying to run a terraria server on a docker with CentOS7 images.

I've set everything up and run it on my server and it can run just fine. But when I tried to run the same configuration in docker, server crash when it finish loading world map with this message.

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at Terraria.Main.startDedInputCallBack (System.Object threadContext) [0x00000] in <filename unknown>:0

Anyone has any idea what causes this?


OK, I've found my solution. And in case anyone that have the same problem as me and found this Post, here is how i do.

Terraria server seems to need a thread which manage input and output stream of command and server log as you saw when you start server. But when I start it in docker, it remove the input output and cause NullReferenceException (System.Object threadContext). So I need a background screen which can still attach to it and have a command line.

I've try tmux in docker but it failed too. But after googling for sometime. I found this post which use systemd service.

So here it is.

1. install screen using apt-get install or yum install

2. create a service file /etc/systemd/system/terraria.service

Description=server daemon for terraria

ExecStart=/usr/bin/screen -dmS terraria /bin/bash -c "/opt/terraria/TerrariaServer.bin.x86_64 -config /srv/terraria/config.txt"
ExecStop=/usr/local/bin/terrariad exit

Dont' forget to change the path to server file and config to match yours.

3. run command "systemctl start terraria" to start service and "systemctl enable terraria" to enable it to run each time server started.

For more detail. Please follow the original post that I found https://www.linode.com/docs/applications/game-servers/host-a-terraria-server-on-your-linode.


Thanks for sharing your solution MoMelyz, I ran into the same issue running Terraria in a Docker container, and your post helped me come up with a fix. I think your solution is a bit overkill though, to provide stdout/TTY to the container all you need to do is add the -it flags to your docker run command. No need to mess with screen and systemctl!
Top Bottom