DCIM / IPAM
    PostgreSQL

    Deploy NetBox on a VPS

    Self-host NetBox, the network source of truth and DCIM/IPAM platform, on a RamNode VPS with PostgreSQL, Redis, Gunicorn, systemd, and nginx TLS.

    Target: single-node NetBox install behind Nginx, PostgreSQL, Redis, and Gunicorn, running as a systemd service. Sized for a 2 vCPU / 4GB RamNode KVM instance; bump PostgreSQL shared_buffers and worker counts for larger fleets.

    0. Assumptions

    • Fresh Ubuntu 24.04 LTS VPS, non-root sudo user
    • Hostname resolvable (e.g. netbox.ramnode.internal or public FQDN with A record)
    • Latest stable NetBox release at time of writing tracks the v4.x branch — check https://github.com/netbox-community/netbox/releases and adjust VERSION below

    1. Base packages

    shell
    sudo apt update && sudo apt upgrade -y
    sudo apt install -y python3 python3-pip python3-venv python3-dev \
        build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev \
        libssl-dev zlib1g-dev git redis-server curl

    2. PostgreSQL

    RamNode's Ubuntu 24.04 image ships PostgreSQL 16 in the default repos.

    shell
    sudo apt install -y postgresql postgresql-contrib
    sudo systemctl enable --now postgresql

    Create DB and user:

    shell
    sudo -u postgres psql <<'EOF'
    CREATE DATABASE netbox;
    CREATE USER netbox WITH PASSWORD 'CHANGE_ME_STRONG_PW';
    ALTER DATABASE netbox OWNER TO netbox;
    GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
    \c netbox
    GRANT ALL ON SCHEMA public TO netbox;
    EOF

    Verify:

    shell
    psql --username netbox --password --host localhost netbox -c "SELECT 1;"

    3. Redis

    Already installed above. Confirm it's up and not exposed off-loopback:

    shell
    sudo systemctl enable --now redis-server
    redis-cli ping   # expect PONG
    grep -E '^bind' /etc/redis/redis.conf   # should be 127.0.0.1 only

    4. Fetch NetBox

    shell
    sudo mkdir -p /opt/netbox
    sudo chown "$USER":"$USER" /opt/netbox
    cd /opt
    VERSION=v4.2.3   # pin to current stable — check releases page
    git clone --branch "$VERSION" --depth 1 https://github.com/netbox-community/netbox.git
    sudo ln -s /opt/netbox /opt/netbox/current 2>/dev/null || true

    Create the dedicated system user NetBox expects:

    shell
    sudo adduser --system --group netbox
    sudo chown --recursive netbox /opt/netbox/media /opt/netbox/reports /opt/netbox/scripts 2>/dev/null

    5. Configuration

    shell
    cd /opt/netbox/netbox/netbox/
    cp configuration_example.py configuration.py

    Generate a secret key:

    shell
    python3 /opt/netbox/netbox/netbox/generate_secret_key.py

    Edit configuration.py:

    shell
    ALLOWED_HOSTS = ['netbox.example.com', '<vps-public-ip>']
    
    DATABASE = {
        'NAME': 'netbox',
        'USER': 'netbox',
        'PASSWORD': 'CHANGE_ME_STRONG_PW',
        'HOST': 'localhost',
        'PORT': '',
        'CONN_MAX_AGE': 300,
    }
    
    REDIS = {
        'tasks': {
            'HOST': 'localhost',
            'PORT': 6379,
            'PASSWORD': '',
            'DATABASE': 0,
            'SSL': False,
        },
        'caching': {
            'HOST': 'localhost',
            'PORT': 6379,
            'PASSWORD': '',
            'DATABASE': 1,
            'SSL': False,
        },
    }
    
    SECRET_KEY = '<paste generated key>'

    6. Install app + run migrations

    NetBox ships an upgrade script that handles venv creation, pip installs, migrations, and static collection in one pass:

    shell
    cd /opt/netbox
    sudo ./upgrade.sh

    This creates /opt/netbox/venv. Activate it for the remaining manual steps:

    shell
    source /opt/netbox/venv/bin/activate
    cd /opt/netbox/netbox

    Create the superuser:

    shell
    python3 manage.py createsuperuser

    7. Gunicorn + systemd

    shell
    cd /opt/netbox
    sudo cp contrib/gunicorn.py /opt/netbox/gunicorn.py
    sudo cp contrib/netbox.service contrib/netbox-rq.service /etc/systemd/system/
    sudo systemctl daemon-reload
    sudo systemctl enable --now netbox netbox-rq
    sudo systemctl status netbox --no-pager

    Check logs if it fails to bind:

    shell
    journalctl -u netbox -n 50 --no-pager

    8. Nginx (TLS-terminated reverse proxy)

    shell
    sudo apt install -y nginx
    sudo cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
    sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
    sudo rm -f /etc/nginx/sites-enabled/default

    Edit /etc/nginx/sites-available/netbox, set server_name to your FQDN, and point ssl_certificate/ssl_certificate_key at real certs. If you don't have certs yet, use certbot:

    shell
    sudo apt install -y certbot python3-certbot-nginx
    sudo certbot --nginx -d netbox.example.com

    Then:

    shell
    sudo nginx -t
    sudo systemctl reload nginx

    9. Firewall

    shell
    sudo ufw allow OpenSSH
    sudo ufw allow 80,443/tcp
    sudo ufw enable

    If RamNode's network doesn't use ufw/iptables directly and you're behind their perimeter firewall/security groups instead, open 80/443 there and skip ufw for the app tier.

    10. Housekeeping

    • sudo systemctl enable --now netbox-housekeeping.timer if present in your version's contrib dir — runs nightly cleanup (expired sessions, changelog pruning).
    • Add a cron/backup job for pg_dump netbox before any upgrade.
    • Upgrades: git fetch --tags, checkout new tag, re-run upgrade.sh, restart netbox + netbox-rq.

    11. Smoke test

    shell
    curl -Ik https://netbox.example.com/

    Expect 200 OK (or 302 to /login/). Log in with the superuser account and confirm the dashboard loads.