Skip to content

Instantly share code, notes, and snippets.

@mmercedes
Last active April 25, 2025 14:27
Show Gist options
  • Save mmercedes/64428eac49d970d6bcac99718a0066a3 to your computer and use it in GitHub Desktop.
Save mmercedes/64428eac49d970d6bcac99718a0066a3 to your computer and use it in GitHub Desktop.
Guide for creating a dedicated valheim server on debian

recommened you do this from within tmux since the steamcmd utility creates its own repl

Install SteamCMD

taken from here

$ sudo useradd -m steam
$ sudo apt update && sudo apt-get install lib32gcc1 -y
$ sudo su - steam
$ mkdir ~/Steam && cd ~/Steam
$ curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
$ ./steamcmd.sh

The last command should bring you into a steam client repl. From here you can login with your steam account (only required once) so Valheim can downloaded.

Steam> login <steam_username>
# this will prompt for password and two-factor auth
Steam> exit

Install Valheim server

Download Valheim from steam into steam user's homedir

$ mkdir ~/Valheim
$ ./steamcmd.sh +login <steam_username> +force_install_dir /home/steam/Valheim +app_update 896660 validate +exit

Now to make a copy of the server start script and create a systemctl service for it so can be auto ran on boot

cp ~/Valheim/start_server.sh ~/Valheim/start_server_local_copy.sh
nano ~/Valheim/start_server_local_copy.sh

Add this line to the local copy of the server start script so that it authenticates via your steam account prior to launching. Should go right after the echo "Starting server... line and fill in the value for your steam username

/home/steam/Steam/steamcmd.sh +login <steam_username> +force_install_dir /home/steam/Valheim +app_update 896660 +quit

Next edit the values for -name -world and -password in the line that looks like this:

./valheim_server.x86_64 -name "My server" -port 2456 -world "Dedicated" -password "secret"

Save the file and exit nano

Create and start systemd service

touch ~/valheim.service
nano ~/valheim.service

In Nano, paste and save the following

[Unit]
Description=Valheim service
Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=10
User=steam
WorkingDirectory=/home/steam/Valheim
ExecStart=/bin/bash /home/steam/Valheim/start_server_local_copy.sh

[Install]
WantedBy=multi-user.target

Now to actually create/start the systemd service, switch back to a user with root access as the steam user will not

sudo cp /home/steam/valheim.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl start valheim

after a few seconds, you can check the status of the server process with

sudo systemctl status valheim

once its looks good, enable the service to run automatically at boot

sudo systemctl enable valheim

Enable port forwarding

Out of the scope of this as its highly dependent on your setup, but you will need to open port 2456 for public traffic before users will be able to connect to your server remotely

Copying worlds

you can simply copy/replace the entire worlds folder if you want to transfer your current world to the new server

Windows location:

C:\Users\snipe\AppData\LocalLow\IronGate\Valheim\worlds

Linux location:

~/.config/unity3d/IronGate/Valheim/worlds
@dweremeichik
Copy link

lib32gcc1 has been renamed to lib32gcc-s1 in Debian 11 (Bullseye)

Copy link

ghost commented Feb 1, 2022

Valheim Dedicated Server now requires to be connected anonymously into SteamCMD instead of being connected through your own steam account

Thanks for the tutorial !

@smooth-baking-powder
Copy link

curl is not installed on debian.
Pls add curl in the installpart :)

@CyberXnerd
Copy link

Hi
So i tried a lot but i can't get it to work.
Or at least when i check the status it says aktive but i can't connect to the server.
Ports are forwarded, i can ping the machine and in game the name of the server is recognized when i enter the IP. But i can't get a connection.
On a win 10 machine i got it up and Ranking in a few minutes but on debian 10 i don't get it to work. Already wrote on a debian cummunity and got roasted because it seems i am stupid cause i can't get it running but no one can tell me the somution as well. So can somone here help me please?

@pugainhd
Copy link

pugainhd commented Apr 4, 2023

For anyone trying this, make sure the start_server_local_copy.sh does not have "-crossplay" for some reason it stops any traffic from entering the correct port.

@pugainhd
Copy link

CMD installation out of date. After reupdating, can update the server with steamcmd +login anonymous +force_install_dir /home/steam/Valheim +app_update 896660 validate +exit

@professorcheechi
Copy link

For anyone trying this, make sure the start_server_local_copy.sh does not have "-crossplay" for some reason it stops any traffic from entering the correct port.

thank you for this.

@benjaminb24
Copy link

In the local server script, these were the lines I had to customize to get this to work on Debian 12

/home/steam/Steam/steamcmd.sh +force_install_dir /home/steam/Valheim +login anonymous +app_update 896660 validate +quit
./valheim_server.x86_64 -name "BsWorld" -port 2456 -nographics -batchmode -world "BsDedicatedWorld" -password "12045" -public 1

As well as the download "curl" portion and lib32gcc1 has been renamed to lib32gcc-s1

@jamzy118
Copy link

jamzy118 commented Nov 3, 2024

I've run into error

dlopen failed trying to load:
/home/steam/.steam/sdk64/steamclient.so
with error:
/home/steam/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory

fixed with:

root@server /h/steam# ln -s /home/steam/Steam/linux64/ /home/steam/.steam/sdk64
root@server /h/steam# ln -s /home/steam/Steam/linux32/ /home/steam/.steam/sdk32

now works great, thanks.

@Azrael907
Copy link

For anyone trying this, make sure the start_server_local_copy.sh does not have "-crossplay" for some reason it stops any traffic from entering the correct port.

Couldn't connect until i removed that. Was running low on sanity. Thank you so much!!

@martinskalicky
Copy link

Was not working for me out of the box. (Debian 12)
Sharing my experience.

Error I was fighting:

Connecting anonymously to Steam Public...OK
Waiting for client config...OK
Waiting for user info...OK
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Error! App '896660' state is 0x2 after update job.

Log error output:

AppID 896660 state changed : Update Required,Update Queued, (No connection)
AppID 896660 state changed : Update Required, (Update delayed for 30 secs)
AppID 896660 scheduler finished : removed from schedule (result No connection, state 0xa)

I had to install steamcmd with

sudo apt update; sudo apt install software-properties-common; sudo apt-add-repository non-free; sudo dpkg --add-architecture i386; sudo apt update
sudo apt install steamcmd

Switching to steam user and running

/usr/games/steamcmd +force_install_dir /home/steam/Valheim +login anonymous +app_update 896660 validate +quit

Success! App '896660' fully installed.

@martinskalicky
Copy link

Also one more note (for Debian 12)

If you want to have -crossplay enabled.

sudo apt install libpulse-dev libatomic1 libc6

@martinskalicky
Copy link

Another note (crossplay enabled)

If you encounter problem that you can see server, you are able to join and then receive DC (you see empty map pretty much).

It was a problem with VPN. After pausing it, all works fine. Another solution might be to switch off firewall (I do not recommend). I did it for troubleshooting.

@Akorian
Copy link

Akorian commented Apr 25, 2025

Hi, just used this to launch my first Valheim Server - but I also like to keep my stuff updated. So how do I install updates to the game AND to the steamcmd? Can I just re-execute the commands to download it or will that overwrite to much?

@martinskalicky
Copy link

martinskalicky commented Apr 25, 2025

@Akorian

$ mkdir ~/Valheim
$ ./steamcmd.sh +login <steam_username> +force_install_dir /home/steam/Valheim +app_update 896660 validate +exit

This will give you that update. I recommend backup for every update.
You can easily get custom config + world and then re-create whole thing using install commands. That's easy way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment