[2.0.16] Cannot reach headless

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Daskepeder
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 10, 2024 8:13 pm
Contact:

[2.0.16] Cannot reach headless

Post by Daskepeder »

I have a Debian 11 server with a recurring error that I have no idea why or how it happens, and usually, I also have no clue why it suddenly starts working again.

Here’s the situation:
11-10-2024, 21-21-37.png
11-10-2024, 21-21-37.png (1.12 MiB) Viewed 234 times

I set up the server for the first time on version 20.0.10. I tried configuring it according to the Factorio Multiplayer wiki, and the server always shows up in the "public games" list. However, more often than not, the server is unreachable. When this happens, I try stopping and starting the service, rebooting the server, and manually restarting the server. After some time, it might just start working again, though I’m not sure what triggered it.

I suspect the issue could be related to how I’ve set up the server, as I’m not an experienced Linux server admin, but I don’t know for sure. The server is also running other services.


I’ve created a script that runs nightly to check for updates. Here’s what it looks like:

Code: Select all

# Stop the Factorio service
sudo systemctl stop factorio.service
sleep 5

# Switch to the Factorio user
sudo su - factorio <<'EOF'
sleep 5

# Set the directory
cd /home/factorio
sleep 5

# Download the latest version as a temporary file
wget -O factorio_latest.tar.xz https://www.factorio.com/get-download/latest/headless/linux64
sleep 5

# Check if the new download is identical to the existing version
if cmp -s factorio_latest.tar.xz factorio.tar.xz; then
  sleep 5
  echo "No new update available. Exiting."
  rm factorio_latest.tar.xz
  sleep 5
else
  # New update found; replace the old file and update Factorio
  mv factorio_latest.tar.xz factorio.tar.xz
  sleep 5
  tar xJvf factorio.tar.xz
  sleep 5
  echo "Factorio has been updated to the latest version."
fi

# Exit from Factorio user
EOF
sleep 5
The server-settings.json file looks like this:
11-10-2024, 22-37-46.png
11-10-2024, 22-37-46.png (124.04 KiB) Viewed 234 times

I cannot see a reason why it shouldn't work, as was hoping for some help here. Don't make me go back to Windows!
Daskepeder
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 10, 2024 8:13 pm
Contact:

Re: [2.0.16] Cannot reach headless

Post by Daskepeder »

User avatar
vinzenz
Factorio Staff
Factorio Staff
Posts: 341
Joined: Mon Aug 02, 2021 6:45 pm
Contact:

Re: [2.0.16] Cannot reach headless

Post by vinzenz »

Constantly re-downloading the headless server is a good way to get throttled by our servers. Please use the API provided here: https://factorio.com/api/latest-releases before downloading a new release. You can also check the factorio log file for errors.

There's also a docker image provided by the community that helps with all the linux hosting issues: https://github.com/factoriotools/factorio-docker
bringing the oops to devops
Daskepeder
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 10, 2024 8:13 pm
Contact:

Re: [2.0.16] Cannot reach headless

Post by Daskepeder »

So the fact that I have downloaded the server software to many times, might actually be the real problem? :shock:
Sorry about that. I thought once a day wasn't so bad.

I'll look into the API and report back. Thank you.
Daskepeder
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 10, 2024 8:13 pm
Contact:

Re: [2.0.16] Cannot reach headless

Post by Daskepeder »

Just wanted to tell that after updating the script with the API as told in the post, this all came together. Thank you. Update script looks like this now (sorry for norwegian comments):

Code: Select all

#!/bin/bash

# Definer sti til versjonsfilen
version_file="/home/factorio/version.txt"

# Hente informasjon om siste stabile versjon fra API
latest_version=$(curl -s https://factorio.com/api/latest-releases | jq -r '.stable.headless')

# Sjekke om resultatet er gyldig
if [ -z "$latest_version" ] || [ "$latest_version" == "null" ]; then
  echo "FEIL: Kunne ikke hente siste stabile headless-versjon fra API."
  exit 1
fi

echo "Siste stabile headless-versjon: $latest_version"

# Sjekk om versjonsfilen eksisterer
if [ ! -f "$version_file" ]; then
  echo "Versjonsfil ikke funnet. Antar ingen versjon installert."
  current_version="none"
else
  # Les gjeldende versjon fra filen
  current_version=$(cat "$version_file")
fi

echo "Nåværende installerte versjon: $current_version"

# Sammenligne versjoner
if [ "$latest_version" != "$current_version" ]; then
  echo "Ny versjon tilgjengelig: $latest_version. Starter oppdateringsprosessen..."

  # Stopp Factorio-tjenesten
  echo "Stopper Factorio-tjenesten..."
  sudo systemctl stop factorio.service || { echo "FEIL: Klarte ikke stoppe Factorio-tjenesten."; exit 1; }

  # Bytte til Factorio User
  sudo su - factorio -c "
  echo 'Laster ned versjon $latest_version...'
  wget -O /home/factorio/factorio_latest.tar.xz https://www.factorio.com/get-download/stable/headless/linux64 || {
    echo 'FEIL: Klarte ikke laste ned nyeste versjon.';
    exit 1;
  }

  echo 'Pakker ut ny versjon...'
  tar -xJf /home/factorio/factorio_latest.tar.xz -C /home/factorio || {
    echo 'FEIL: Klarte ikke pakke ut den nye versjonen.';
    exit 1;
  }

  echo '$latest_version' > /home/factorio/version.txt
  echo 'Oppdatering fullført. Ny versjon ($latest_version) lagret i /home/factorio/version.txt.'
  "

  echo "Tilbake til opprinnelig bruker."

  # Start Factorio-tjenesten
  echo "Starter Factorio-tjenesten på nytt..."
  sudo systemctl start factorio.service || { echo "FEIL: Klarte ikke starte Factorio-tjenesten."; exit 1; }
  echo "Factorio-tjenesten er startet med ny versjon $latest_version."
else
  echo "Serveren er allerede oppdatert til den nyeste versjonen: $latest_version."
fi
Daskepeder
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 10, 2024 8:13 pm
Contact:

Re: [2.0.16] Cannot reach headless

Post by Daskepeder »

Aaaaand, I was wrong. I am absolutely clueless. Updates are no longer an issue. I haven't downloaded anything for many days. Symptoms are exactly the same. Server is in list and cannot be reached. No amount of restarts of both the server and the software helps. At some point it just starts working again...
Post Reply

Return to “Technical Help”