Log inSign up

NetBox as the source of truth for your network

Clone the release branch of netbox-docker, replace the default passwords and secret key in the env files, publish the web container on 127.0.0.1:8000 with an override file, and run docker compose up -d. Create a superuser with manage.py createsuperuser, then serve netbox.example.net through Nginx with a Let's Encrypt certificate.

Topic: Self-hosted apps · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What does NetBox do and what does it need?

NetBox models your infrastructure: sites, racks, devices, cables, IP prefixes and addresses, VLANs, circuits and virtual machines, with a full REST and GraphQL API on top. Teams use it as the authoritative record that automation tools read from.

The Docker deployment runs NetBox, a background worker, a housekeeping job, PostgreSQL and two Redis instances. Give it at least 2 GB of memory; 4 GB is more comfortable once you import data or add plugins. Disk needs are small unless you attach many images to devices.

Prepare a sudo user (first SSH session), Docker with the Compose plugin (Docker Engine or the Docker image), git, and DNS records for netbox.example.net.

How do you get netbox-docker?

The community project keeps a release branch that always matches a tested NetBox version. Clone it into /opt:

sudo git clone -b release https://github.com/netbox-community/netbox-docker.git /opt/netbox-docker
sudo chown -R deploy: /opt/netbox-docker
cd /opt/netbox-docker
ls env

The env folder holds one file per service: netbox.env, postgres.env, redis.env and redis-cache.env. They ship with sample passwords that are public, so the next step is mandatory.

Which secrets must you change?

Generate fresh values and edit the files so that each pair matches:

openssl rand -hex 24          # database password
openssl rand -hex 24          # redis password
openssl rand -hex 24          # redis cache password
openssl rand -base64 60 | tr -d "\n=+/"   # SECRET_KEY
  • DB_PASSWORD in netbox.env equals POSTGRES_PASSWORD in postgres.env.
  • REDIS_PASSWORD in netbox.env equals the password in redis.env.
  • REDIS_CACHE_PASSWORD in netbox.env equals the password in redis-cache.env.
  • SECRET_KEY must be at least 50 characters and stay constant; changing it logs everyone out.

Also set CSRF_TRUSTED_ORIGINS=https://netbox.example.net in netbox.env so form posts through the proxy are accepted.

How do you start NetBox and create the first user?

The main Compose file does not publish any port. Add an override file that exposes the web container on the loopback address only:

cat > docker-compose.override.yml <<EOF
services:
  netbox:
    ports:
      - "127.0.0.1:8000:8080"
EOF
docker compose pull
docker compose up -d

The first start runs database migrations and can take several minutes; docker compose ps shows the netbox service as healthy when it is ready. Then create an administrator:

docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
curl -sI http://127.0.0.1:8000/login/ | head -n 1

The curl line should print an HTTP 200 status. The NetBox version appears in the footer of every page once you log in.

How do you publish NetBox over HTTPS?

Use Nginx with Certbot. On Ubuntu and Debian install nginx certbot python3-certbot-nginx with apt; on Rocky and Alma install epel-release, the same packages with dnf, and allow proxy connections with sudo setsebool -P httpd_can_network_connect 1. Create /etc/nginx/conf.d/netbox.conf:

server {
    listen 80;
    listen [::]:80;
    server_name netbox.example.net;
    client_max_body_size 25m;
    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d netbox.example.net

Allow only web ports through the firewall: sudo ufw allow 80,443/tcp, or the http and https services with firewall-cmd on Rocky and Alma. A Caddy alternative is described in Caddy HTTPS.

How do you start modelling your network?

NetBox works best when you build from the top down. A practical order is:

  1. Create a site for each location, then racks inside it.
  2. Add manufacturers, device types and device roles; the community device type library offers ready definitions you can import.
  3. Create devices, their interfaces and the cables between them.
  4. Enter prefixes such as 198.51.100.0/24 and 2001:db8:4f2a::/48, then assign IP addresses to interfaces.

Bulk import accepts CSV, JSON or YAML on every list page, which saves time when you migrate from spreadsheets. Custom fields and tags cover data the core model does not include.

How do you use the NetBox API?

Create a token under your user profile, then call the REST API. Recent NetBox releases issue tokens that are sent as a Bearer header, while older tokens use the Token scheme; the token page shows which format yours needs.

TOKEN=paste-your-token
curl -s -H "Authorization: Token $TOKEN" -H "Accept: application/json" \
  https://netbox.example.net/api/status/
curl -s -H "Authorization: Token $TOKEN" \
  "https://netbox.example.net/api/ipam/prefixes/?limit=5"

The status endpoint returns the NetBox, Python and plugin versions, which makes it a quick health check for monitoring. For scripting, the pynetbox Python library wraps the same API; see Python and pip for setting up a virtual environment.

How do you configure mail, backups and upgrades?

NetBox sends mail for error reports and some plugins. Set EMAIL_SERVER, EMAIL_PORT=587, EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_USE_TLS=true and EMAIL_FROM in netbox.env, pointing at an authenticated relay. Do not rely on port 25 being open outbound; ask support through a ticket before planning direct delivery.

Back up the database and uploaded media regularly:

cd /opt/netbox-docker
docker compose exec -T postgres pg_dump -U netbox netbox | gzip > ~/netbox-$(date +%F).sql.gz
docker run --rm -v netbox-docker_netbox-media-files:/m -v ~/:/b alpine tar czf /b/netbox-media-$(date +%F).tgz -C /m .

To upgrade, update the branch, pull images and recreate; migrations run automatically:

git pull -p origin release
docker compose pull
docker compose up -d

Read the NetBox release notes for major versions, which sometimes require a newer PostgreSQL. Check volume names with docker volume ls if the backup command reports a missing volume.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-2a small lab inventory1 vCPU, 2 GB RAM, 50 GB NVMe$7.20/mo$43.20 for 6 months
A2-4a company network with plugins2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months

Questions about NetBox network inventory

Is NetBox a monitoring tool?

No. It records how the network should look. Pair it with a monitoring system such as Zabbix or Grafana that reads devices from NetBox.

Can I install NetBox without Docker?

Yes, the official documentation describes a native install with PostgreSQL, Redis, Python, Gunicorn and Nginx. Docker keeps upgrades simpler on a single server.

How do I add plugins?

Build a custom image from the netbox-docker Dockerfile that installs the plugin with pip, then list it in the plugins configuration. Test plugins against your NetBox version first.

Why do forms fail with a CSRF error?

CSRF_TRUSTED_ORIGINS does not include the exact HTTPS address users open, or the proxy does not pass the Host header.

Is LDAP or single sign-on supported?

NetBox supports LDAP and many SSO providers through its authentication settings. In the Docker setup these are configured through environment variables and extra config files.