Tutorials 15 min read

Recycle an Old PC into a Home Server in 2026

Recycle an old PC into a home server in 2026: which PC to keep (64-bit, RAM, SSD), BIOS settings, Ubuntu Server LTS, official Docker, Nextcloud, MariaDB and Caddy over HTTPS.

S By Selfhostr · no sponsored content
Recycle an Old PC into a Home Server in 2026
This article may contain affiliate links (no extra cost to you, it funds the site). As an Amazon Associate, Selfhostr earns from qualifying purchases. See the disclosure.

👍 What we like

  • Gives existing hardware a second life, with no purchase beyond a domain name.
  • Automatic HTTPS with Caddy, in a few lines of config.
  • Nextcloud only listens on 127.0.0.1 and stays behind the reverse proxy.
  • Simple updates and backups thanks to Docker Compose.

👎 What to watch

  • Exposing it to the Internet requires a public IPv4 address, which doesn't work behind CGNAT without a tunnel or VPN.
  • Used hardware needs drive monitoring (SMART) and serious backups.
  • An old PC or a mini PC has few bays for a real multi-drive NAS.
  • Ports published by Docker bypass UFW and need care.
📑 Contents ▾

Turning an old PC into a home server makes sense if the machine is 64-bit, has at least 4 GB of RAM (8 GB gives you more headroom) and can take an SSD for the system. That covers most desktops and laptops from the 2010s onward. This guide is for anyone who wants a useful first server, here a personal Nextcloud cloud over HTTPS, without buying anything except a domain name. If your old PC is 32-bit, or if it’s a big tower with a dedicated graphics card that heats up the room, a refurbished business mini PC such as the Lenovo ThinkCentre M720q Tiny or the HP ProDesk 600 G5 Mini will do the same job more quietly. Neither one replaces a multi-drive NAS, though.

The stack is Ubuntu Server LTS (24.04 or 26.04), Docker Engine from Docker’s official repository, Nextcloud and MariaDB managed by Docker Compose, and Caddy as the reverse proxy. Caddy gets and renews the Let’s Encrypt certificate on its own. The commands and files were checked against the official Docker, Caddy, Nextcloud and Ubuntu documentation in November 2026. Selfhostr has not tested the two mini PCs mentioned here, so confirm their specs on the spec sheet for your exact configuration.

Which old PC deserves a second life (and which doesn’t)

Check these points before you install anything. They decide whether the machine can work as a server.

  • 64-bit is mandatory. Docker Engine only runs on 64-bit versions of Ubuntu, and Nextcloud strongly recommends a 64-bit CPU, OS and PHP. A 32-bit PC won’t work for this guide.
  • RAM matters more than the CPU. Nextcloud recommends at least 512 MB per PHP process. With MariaDB, the OS and a service or two more, 4 GB is enough to get started, and 8 GB means you won’t have to revisit it. On a desktop, a used memory stick is often the best money you can spend. Check the memory type (DDR3 or DDR4) before you buy one.
  • The original drive is the first suspect. A ten-year-old hard drive slows everything down and may fail. A SATA SSD for the system makes far more difference than any CPU. Either way, run the SMART test in step 2 on every drive you keep.
  • A dedicated graphics card is useless here. A Nextcloud server runs without a monitor. If the CPU has integrated graphics, pulling the dedicated card removes a source of heat and power draw. To find out what the machine really draws, measure it with a plug-in power meter: published figures for an old PC are no substitute for a measurement.
  • Laptop or desktop. A laptop usually draws little power, and its battery rides through brief power cuts. An old battery can swell, though: inspect it, and remove it if it’s deformed. You also need to stop the laptop from sleeping when the lid is closed (see below).
  • Number of drives. A typical desktop often takes several SATA drives. A mini PC or a laptop takes only one or two. For a real NAS with redundancy, it’s the wrong starting point.

If you don’t have a PC to recycle, the refurbished mini PC guide compares the Lenovo Tiny, Dell Micro and HP Mini families. The Lenovo ThinkCentre M720q Tiny and the HP ProDesk 600 G5 Mini are compact x86-64 business desktops. They take an M.2 SSD and, depending on the configuration, a 2.5-inch drive, but no 3.5-inch drive. The number of M.2 slots and the maximum RAM vary by model, so check the spec sheet for your exact model number (PSREF for Lenovo, QuickSpecs for HP).

Preparing the machine: BIOS, sleep and closed lid

These are the settings people forget, and they’re why a “recycled” server shuts down and never comes back.

  • Power-loss recovery. In the BIOS or UEFI, look for the option that turns the PC back on when power returns. It’s often called “After Power Loss”, “AC Recovery” or “Restore on AC Power Loss”. Set it to Power On (or Last State). Without it, the machine stays off after a power cut.
  • Booting without a keyboard or monitor. Some old BIOSes stop at boot with a “No keyboard detected” error. Turn that halt off if the option exists, then do a test boot with no keyboard or monitor plugged in.
  • Boot mode. If the machine supports it, install in UEFI mode rather than “Legacy/CSM”.
  • Laptop: closed lid. Otherwise, closing the lid puts the server to sleep. After installation, edit /etc/systemd/logind.conf and set HandleLidSwitch=ignore and HandleLidSwitchExternalPower=ignore. Then reboot to apply the change.

What this setup puts in place

Only Caddy is exposed to the Internet, on ports 80 and 443. Nextcloud only listens on 127.0.0.1:8080, and MariaDB can only be reached from the internal Docker network. SSH stays limited to your local network. To expose Nextcloud to the Internet, you need:

  • A domain name (or a subdomain, such as cloud.example.com) whose DNS zone you manage.
  • A reachable public IPv4 address. If your ISP puts you behind CGNAT, port forwarding won’t work and Let’s Encrypt won’t be able to validate the domain. Ask your ISP for a full public IPv4 address, use a tunnel, or skip public exposure and use a mesh VPN: the Tailscale tutorial shows that approach.
  • Access to your router’s interface to create a DHCP reservation and forward TCP ports 80 and 443. Forward nothing else, and certainly not port 22.
  • A USB stick of at least 4 GB for the installer. Everything on it will be erased.

Step 1: Create the USB installer

Download the Ubuntu Server ISO, version 24.04 LTS or 26.04 LTS. According to Canonical’s published release cycle, standard support runs until May 2029 for 24.04 and until May 2031 for 26.04. 20.04 has had none since May 2025, so don’t use it. Check the image’s integrity first (the SHA256SUMS file is on the release’s download page):

sha256sum -c SHA256SUMS --ignore-missing

The output must show OK next to the ISO name.

⚠️ Warning: the dd command below wipes the whole target device. Make sure you’ve identified the stick correctly first. Plug it in, run lsblk, then compare its size (SIZE), model (MODEL) and transport (TRAN = usb):

lsblk -o NAME,SIZE,MODEL,TRAN,MOUNTPOINTS
# Remplacez /dev/sdX par la clé identifiée ci-dessus (PAS votre disque système)
sudo dd if=ubuntu-*-live-server-amd64.iso of=/dev/sdX bs=4M status=progress conv=fsync

Check: run lsblk again. The stick should now contain the installer’s partitions.

Step 2: Install Ubuntu Server and check the hardware

Boot the PC from the stick (F12, F10 or Esc depending on the manufacturer). In the installer:

  1. Pick the target disk. ⚠️ “Use an entire disk” wipes that disk. On a recycled PC, the old Windows install and family files are often still there: back up anything you need, and check the model and size shown.
  2. Create your user. It is not root: every admin command will go through sudo.
  3. Tick Install OpenSSH server.

After the reboot, log in and update the system:

sudo apt update && sudo apt full-upgrade -y
sudo apt install -y smartmontools dnsutils

Check: confirm the installed version, then the hardware health. On a used machine, this is the step you can’t skip. The disk should report PASSED on the SMART test (use /dev/sda or /dev/nvme0n1 depending on lsblk). If dmesg shows I/O errors on the disk, replace it before going any further.

lsb_release -d
lsblk -o NAME,SIZE,MODEL,TYPE
free -h
sudo smartctl -H /dev/sda
sudo dmesg --level=err,crit,alert,emerg

Ubuntu Server turns on automatic security updates by default. To confirm:

systemctl is-active unattended-upgrades
cat /etc/apt/apt.conf.d/20auto-upgrades

The service should be active, and both lines in the file should be set to "1".

Step 3: Network, DNS and port forwarding

  1. On your router, create a DHCP reservation for the server’s MAC address. It’s simpler and less error-prone than a static IP in netplan. Note its local address:
ip -4 addr show
  1. At your registrar, create an A record for cloud.example.com that points to your router’s public IPv4 address (shown in its interface).
  2. On the router, forward only TCP ports 80 and 443 to the server’s local IP.

Check: DNS should return your public IP:

dig +short A cloud.example.com

Step 4: Install Docker Engine from the official repository

Ubuntu’s docker.io package doesn’t ship the docker compose plugin used below, and it conflicts with the official packages. If an old install is lying around on the machine, Docker’s documentation provides a command that removes the conflicting packages (docker.io, docker-compose, podman-docker, containerd, runc…). Run it first. Then follow the official procedure:

sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker

Check:

systemctl is-enabled docker        # doit afficher : enabled
sudo docker run --rm hello-world   # doit afficher « Hello from Docker! »
sudo docker compose version

Step 5: Deploy Nextcloud and MariaDB with Docker Compose

Create the project folder and a .env file with random passwords that only root can read:

sudo mkdir -p /opt/nextcloud && cd /opt/nextcloud
sudo tee .env >/dev/null <<EOF
MYSQL_ROOT_PASSWORD=$(openssl rand -base64 24)
MYSQL_PASSWORD=$(openssl rand -base64 24)
NC_ADMIN_PASSWORD=$(openssl rand -base64 24)
NC_DOMAIN=cloud.example.com
EOF
sudo chmod 600 .env

Replace cloud.example.com with your domain (sudo nano .env). Then create /opt/nextcloud/compose.yaml. According to the Nextcloud image documentation, the image reads MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD and MYSQL_HOST. If any of these four is missing, it falls back to SQLite, which Nextcloud reserves for testing.

services:
  db:
    image: mariadb:lts
    restart: always
    command: --transaction-isolation=READ-COMMITTED
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud:stable
    restart: always
    ports:
      - "127.0.0.1:8080:80"   # joignable uniquement depuis le serveur (Caddy)
    depends_on:
      - db
    volumes:
      - ./nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=${NC_ADMIN_PASSWORD}
      - NEXTCLOUD_TRUSTED_DOMAINS=${NC_DOMAIN}
      - TRUSTED_PROXIES=172.16.0.0/12
      - APACHE_DISABLE_REWRITE_IP=1
      - OVERWRITEPROTOCOL=https
      - OVERWRITECLIURL=https://${NC_DOMAIN}

restart: always restarts the containers after the server reboots. TRUSTED_PROXIES=172.16.0.0/12 covers the gateway of Docker’s default networks, which is where requests relayed by Caddy come from. Change this range if you’ve customized your Docker networks. The image documentation recommends APACHE_DISABLE_REWRITE_IP=1 when a proxy is declared, so that Nextcloud reads the client’s real address. If you’re putting the data on a second drive, mount it first (in /srv, for example) and point the ./nextcloud volume at that path before the first start.

cd /opt/nextcloud
sudo docker compose up -d
sudo docker compose logs -f app   # Ctrl+C quand l'initialisation est terminée

Check: both containers should be Up, and occ status should report installed: true. On an old CPU or a slow drive, the first install can take several minutes.

sudo docker compose ps
sudo docker compose exec -u www-data app php occ status
sudo grep NC_ADMIN_PASSWORD .env   # mot de passe du compte « admin »

Step 6: Install Caddy and enable HTTPS

Install Caddy from its official repository:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
sudo chmod o+r /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install -y caddy

Replace /etc/caddy/Caddyfile (it isn’t YAML) with the file below. The .well-known redirects are needed for CalDAV and CardDAV. They follow the Caddy example in the Nextcloud reverse proxy documentation:

sudo tee /etc/caddy/Caddyfile >/dev/null <<'EOF'
cloud.example.com {
    redir /.well-known/carddav /remote.php/dav/ 301
    redir /.well-known/caldav /remote.php/dav/ 301
    header Strict-Transport-Security "max-age=15552000; includeSubDomains"
    reverse_proxy 127.0.0.1:8080
}
EOF
sudo sed -i 's/cloud.example.com/VOTRE-DOMAINE/' /etc/caddy/Caddyfile   # adaptez
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy

Check: the curl command should return HTTP/2 200 and a JSON containing "installed":true. If it fails, Caddy’s logs show why the certificate was refused.

curl -sI https://cloud.example.com/status.php | head -n 1
curl -s https://cloud.example.com/status.php
sudo journalctl -u caddy --no-pager | tail -n 30

Step 7: Firewall, background jobs and power-cut test

Enable UFW. Allow SSH from your local network only (adjust 192.168.1.0/24) before you enable it, or you’ll lock yourself out:

sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

Note: Docker’s documentation states that ports published by Docker bypass UFW rules. That’s why Nextcloud is published on 127.0.0.1 only.

Nextcloud recommends running cron.php every 5 minutes. Add the job to root’s crontab (sudo crontab -e):

*/5 * * * * docker compose -f /opt/nextcloud/compose.yaml exec -T -u www-data app php -f /var/www/html/cron.php

Then:

sudo docker compose -f /opt/nextcloud/compose.yaml exec -u www-data app php occ background:cron
sudo reboot

Check after the reboot: the containers should be back up on their own, and the site should answer over HTTPS.

sudo docker compose -f /opt/nextcloud/compose.yaml ps
curl -s https://cloud.example.com/status.php

Next, run the test most tutorials skip: pull the power plug for a few seconds, then plug it back in. If the machine doesn’t come back on by itself, go back into the BIOS and set the power-loss recovery option. Don’t run this test during a large write.

Final checks

  • sudo docker compose ps (in /opt/nextcloud): db and app should both be Up. Unlike docker ps -a, this command doesn’t mix in stopped containers from other projects.
  • sudo ss -tlnp | grep -E ':(80|443|8080)\b': Caddy should be listening on 80 and 443, and 8080 only on 127.0.0.1.
  • Open https://cloud.example.com, log in as admin, then go to Administration settings > Overview (account menu, top right). Nextcloud lists its security and setup warnings there.
  • curl -sI https://cloud.example.com/.well-known/caldav should return a 301 to /remote.php/dav/.

Securing and maintaining the server over time

  • Expose only 80 and 443. No port forwarding for SSH, Samba or any admin interface. For remote access, use a VPN (WireGuard or Tailscale, for example).
  • SSH: use key authentication (ssh-copy-id), then set PasswordAuthentication no in /etc/ssh/sshd_config. Keep a session open while you test.
  • Docker socket: never mount it into an exposed container, and think twice before adding a user to the docker group: it amounts to root access.
  • Nextcloud account: enable two-factor authentication (the “Two-Factor TOTP Provider” app) and create a non-admin account for everyday use.
  • Updates: sudo docker compose pull && sudo docker compose up -d. Nextcloud only upgrades one major version at a time. If you pin a version (nextcloud:NN), go up one number at a time.
  • Drives: on used hardware, run sudo smartctl -a from time to time and watch how the reallocated sector count changes.
  • Backups: a single drive in an old PC is not a backup. Put Nextcloud in maintenance mode, dump the database, then copy /opt/nextcloud to another device:
cd /opt/nextcloud
sudo docker compose exec -u www-data app php occ maintenance:mode --on
sudo docker compose exec -T db sh -c 'mariadb-dump --single-transaction -u nextcloud -p"$MYSQL_PASSWORD" nextcloud' | sudo tee /root/nextcloud-db.sql >/dev/null
sudo docker compose exec -u www-data app php occ maintenance:mode --off
sudo head -n 5 /root/nextcloud-db.sql   # vérifie que le dump n'est pas vide

Troubleshooting common errors

  • “Access through untrusted domain”. NEXTCLOUD_TRUSTED_DOMAINS is mainly applied at install time. To add the domain afterwards, run sudo docker compose exec -u www-data app php occ config:system:set trusted_domains 1 --value=cloud.example.com.
  • Caddy can’t get a certificate. Check your domain with dig +short A, check that ports 80 and 443 are forwarded on the router and that you aren’t behind CGNAT, then read sudo journalctl -u caddy.
  • 502 Bad Gateway. Nextcloud isn’t answering on 127.0.0.1:8080. Check sudo docker compose logs app and sudo docker compose ps.
  • Redirect loop or http:// links. Check OVERWRITEPROTOCOL=https and TRUSTED_PROXIES, then occ config:list system.
  • Nextcloud is using SQLite. One of the four MYSQL_* variables was missing on first start. Fix the file, then start again from an empty ./nextcloud folder.
  • Services stopped after a reboot. Check systemctl is-enabled docker and that restart: always is set.
  • The laptop goes to sleep. Check the HandleLidSwitch lines in /etc/systemd/logind.conf (they must not be commented out), then reboot.
  • The server stays off after a power cut. This is a BIOS setting, not a Linux problem (see “Preparing the machine”).

Frequently asked questions

Why Caddy rather than Nginx and Certbot?

Caddy gets and renews Let’s Encrypt certificates automatically, and its config is only a few lines long. Nginx with Certbot also works, but you don’t need it once Caddy is in place. Never run both on ports 80 and 443.

Can I use Debian instead of Ubuntu?

Yes, and Debian is often a little lighter on an old machine. Use the current stable release and the “Install Docker Engine on Debian” procedure from Docker’s documentation (the repository is different). Avoid Debian 11, which reaches the end of its LTS support in 2026.

Can I turn it into a NAS?

Yes for file sharing through Nextcloud. You can add Samba for SMB on the local network, but never expose it to the Internet. A desktop tower with several SATA bays can hold a few drives. A mini PC or a laptop doesn’t have enough for multi-drive RAID.

What should I do with this server next?

The same Docker base can host other services. For home automation, see Home Assistant on a mini PC. If you’re still unsure about hardware, compare Raspberry Pi 5 and mini PCs. Local AI is different: it needs a GPU that a recycled PC rarely has, and the guide to building a local AI server explains why.

What does it cost?

The software used here is free and open source. That leaves the domain name, possibly an SSD or a RAM stick, and electricity, which depends on your hardware and your plan.

Key facts

Ubuntu Server 24.04 or 26.04 LTS
OS
64-bit PC, 4 GB RAM, SSD
Minimum hardware
Intermediate
Difficulty
Free and open source
Software

Our picks

Affiliate links · same price for you
Recommended
📦

Lenovo ThinkCentre M720q Tiny

View on Amazon

Amazon · price and availability on the listing

Alternative
📦

HP ProDesk 600 G5 Mini

View on Amazon

Amazon · price and availability on the listing

See all our recommended gear in the shop.

Tags: homelabrecyclingnasservercloud

Related

Tutorials

Getting Started with Docker Compose in Your Home Lab for 2026

First Docker Compose stack for your homelab: Docker from the official repository, the Compose v2 plugin, Nginx, MariaDB and LAN-only phpMyAdmin, with valid files and a check at every step.

Read
Tutorials

Configure a ZFS cache on your NAS to boost performance in 2026

Optimize your TrueNAS or Proxmox NAS with a ZFS cache (ARC, L2ARC, ZIL) for faster reads and writes while maintaining the reliability of mechanical drives

Read
Tutorials

Metal Rack Assembly for Home Lab 2026: Step-by-Step Guide

Discover our comprehensive and detailed tutorial to install a metal rack in 2026. Follow our practical tips, complete configuration files, and exact commands.

Read