Skip to content

How to Set Up NetBox on a Linux Server – Document Networks, Racks, and IP Addresses

Set up NetBox on a Linux server: use the One-Click App with HTTPS or install it with Docker Compose, then create an admin login, your first racks and IP addresses, and API access.

30 November 202613 min read0 Views0 helpful

Introduction

NetBox is open-source software that lets you document your infrastructure in one place. Technically, this is called DCIM (Data Center Infrastructure Management) and IPAM (IP Address Management): locations, racks, devices, interfaces, and cables on one side, and IP prefixes, IP addresses, VLANs, and VRFs on the other. It also supports provider circuits, virtual machines, VPN tunnels, and custom fields. NetBox is designed to be a “source of truth”: it describes how your network should be structured, and other tools read this data through the REST API or GraphQL.

In this guide, we’ll show you two ways to get started: the easy way with the One-Click App, which provides NetBox over HTTPS with a database, cache, and background worker, and a manual installation using the official NetBox Docker project. Then you’ll create your first objects and set up API access.

When NetBox Makes Sense on a VPS

NetBox is useful as soon as you no longer want your network and server data scattered across spreadsheets and people’s heads. NetBox is a good fit on a VPS if:

  • You want to assign IP addresses and subnets properly, instead of managing them in a spreadsheet. NetBox shows available addresses in a prefix and warns about duplicate entries.
  • You document racks, devices, and cabling, for example in data center server cabinets, an office, or a larger homelab, including rack views and cable paths.
  • Automation needs a reliable data source. Ansible, Terraform, monitoring tools, or your own scripts can retrieve devices, addresses, and VLANs from NetBox through the REST API or GraphQL.
  • Multiple people work on the documentation and you need users, groups, permissions, and a change log.
  • NetBox needs to be available around the clock, independently of your PC at home.

NetBox is less suitable if you only have a handful of devices or want to monitor your network. NetBox is not a monitoring tool: it doesn’t check whether devices are reachable or discover them automatically. To monitor the live status of your servers, use a tool such as Grafana with a suitable data source. And if you only want to plan a server cabinet visually, NetBox’s data model is often more than you need.

The Easy Way: NetBox as a One-Click App

The quickest way to get NetBox is through your VPS’s One-Click Apps. The app starts NetBox with PostgreSQL, two cache instances (Valkey), and a background worker. With a domain, it’s available directly over HTTPS and creates the admin account on first startup. You don’t need a reverse proxy, certificate, or firewall rules.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. For instructions, see Setting Up One-Click Apps.
  • At least 2 GB of RAM; 4 GB of RAM and 2 vCPU cores are recommended. NetBox runs as a stack of five containers: web interface, worker, PostgreSQL, and two Valkey instances.
  • At least 5 GB of free storage; 10 GB is recommended. The NetBox image alone is over 1 GB.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search the app catalog for NetBox and click Install app on its card.
  3. Use a custom subdomain or zap.cloud is already selected, with a random name. Leave the option enabled or enter a custom name, such as netbox or ipam.
  4. You don’t need to fill in anything under App configuration. The app generates seven values automatically, including the passwords for the database, cache, and admin account, as well as NetBox’s secret key.
  5. Click Queue installation.

On first startup, NetBox creates its database and runs several hundred database migrations. In our test, this took just over ten minutes. During this time, the app card shows “The app is not starting properly,” and the background worker restarts several times. This is normal on first startup.

Warning: Don’t redeploy during the first startup

Don’t click Redeploy or Reinstall app during the first 15 minutes. This will interrupt startup and make it take even longer. You can check the progress under Logs on the app card. Once you see Initialisation is done, NetBox is ready and the app card shows the app as online.

First Login: Find Your Credentials

On first startup, the app creates an admin account with the username admin. ZapX generates the password during installation:

  1. Click the gear icon on the app card and go to App environment.
  2. Under Automatically generated values, you’ll find the password in SERVICE_PASSWORD_NETBOXADMIN. Click the eye icon to show it or the icon next to it to copy it.
  3. Open your app using the Access link. NetBox displays the login page with Username and Password fields.
  4. Sign in with the username admin and the password from App environment.

After logging in, you’ll see your personal dashboard with tiles for Organization, IPAM, DCIM, and other areas. The menu on the left lists all object types, and the installed version is shown at the bottom left.

You don’t need the SERVICE_PASSWORD_64_NETBOXAPITOKEN value. You’ll create an API token in NetBox itself, as described below under “API Access.”

Warning: Changing the password in App Environment won’t update it

NetBox only creates the admin account if it doesn’t already exist. If SERVICE_PASSWORD_NETBOXADMIN or other values for the initial account change later, they won’t take effect. Change your password in NetBox itself: click your username in the top-right corner, open Profile, and go to the Password tab. NetBox requires at least 12 characters, including a digit and uppercase and lowercase letters.

Create Individual Accounts Instead of Using admin

The admin account is a superuser with all permissions. If more than one person works with NetBox, create a separate account for each person:

  1. In the menu on the left, go to Admin > Users and click Add.
  2. Enter a Username and password. Assign permissions using Groups and Permissions in the same menu, for example, read-only access for colleagues who need to look things up but shouldn’t make changes.
  3. Save by clicking Create.

Only select the superuser checkbox for accounts that really need full access.

Updates and Backups

Update NetBox in the app settings (gear icon) under App update. Click Check for updates, then install a new version with Apply update. If the page says the app is up to date, there isn’t a newer version in the app catalog yet. The app uses NetBox 4.7 in the NetBox Docker image.

Warning: Back up before updating

When a new version starts, NetBox automatically updates the database. After that, you can only go back to the old version by restoring a backup. So back up the database as described below or back up the entire VPS using Backups in the dashboard.

All objects, users, and settings are stored in the app’s PostgreSQL database, while uploaded images and attachments are stored in the media volume. Both are retained during updates, but a volume is not a backup. Connect to your VPS over SSH and back up the database and media as follows:

Code
N=$(docker ps --format '{{.Names}}' | grep -E '^netbox-[a-z0-9]{24}$')
U=${N#netbox-}
docker exec postgres-$U pg_dump -U netbox -d netbox | gzip > netbox-db-$(date +%F).sql.gz
docker exec $N tar czf - -C /opt/netbox/netbox/media . > netbox-media-$(date +%F).tar.gz

The first line finds the web interface container. The second extracts the installation ID from its name, which is also included in the names of the other containers. Don’t keep the backup only on the VPS itself.

Manual Installation

The rest of this guide covers a manual installation with the official NetBox Docker project, for example, if you don’t use One-Click Apps on your server or want to run NetBox behind your own reverse proxy.

Requirements

  • A Linux VPS running Debian or Ubuntu, with SSH access. See First SSH Access.
  • Docker and Docker Compose (Compose v2), as well as git. See Installing Docker. Check the installation with docker --version and docker compose version, and install git with apt install git.
  • A domain or subdomain whose A record points to your VPS’s IP address (e.g. netbox.example.com).

NetBox Docker doesn’t specify hardware requirements. The figures below are guidelines for a small to medium-sized installation with all five containers:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM2 GB4 GB
Storage5 GB10 GB

Set Up the Firewall

NetBox listens on port 8080 inside the container. You don’t need to open this port if you use a reverse proxy as shown below. With ufw, allow only SSH and the ports used by the reverse proxy:

Code
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Warning: Docker bypasses ufw

Ports published by Docker with ports: are also accessible externally even if ufw blocks them. Docker adds its own rules before those from ufw. Therefore, bind NetBox to 127.0.0.1 as described below. For more information, see Managing the Firewall on Linux.

Install with Docker Compose

NetBox Docker includes a ready-to-use docker-compose.yml and example configuration files. Get the project from the release branch, which always points to the latest stable version:

Code
cd /opt
git clone -b release https://github.com/netbox-community/netbox-docker.git netbox
cd netbox

The files in the env/ folder contain example passwords that are the same for every installation. Replace them with your own random values before the first startup. The following commands generate new passwords, a new secret key, and a pepper for API tokens, then write them directly to the files without displaying them:

Code
DB_PW=$(openssl rand -hex 24)
REDIS_PW=$(openssl rand -hex 24)
CACHE_PW=$(openssl rand -hex 24)
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PW|; s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$REDIS_PW|; s|^REDIS_CACHE_PASSWORD=.*|REDIS_CACHE_PASSWORD=$CACHE_PW|; s|^SECRET_KEY=.*|SECRET_KEY=$(openssl rand -hex 32)|; s|^API_TOKEN_PEPPER_1=.*|API_TOKEN_PEPPER_1=$(openssl rand -hex 32)|" env/netbox.env
sed -i "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$DB_PW|" env/postgres.env
sed -i "s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$REDIS_PW|" env/redis.env
sed -i "s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$CACHE_PW|" env/redis-cache.env
chmod 600 env/*.env

Then create the docker-compose.override.yml file, for example, with nano docker-compose.override.yml. It supplements the supplied docker-compose.yml without changing it:

Code
services:
  netbox:
    ports:
      - "127.0.0.1:8000:8080"
    environment:
      ALLOWED_HOSTS: "netbox.example.com localhost"

Here’s what the files do:

  • docker-compose.yml (included): starts the web interface netbox, the background worker netbox-worker for scripts, webhooks, and synchronization, PostgreSQL as the database, and two Valkey instances for the task queue and cache.
  • env/netbox.env: NetBox configuration. SECRET_KEY must be at least 50 characters long, and API_TOKEN_PEPPER_1 is needed for REST API tokens (see below).
  • 127.0.0.1:8000:8080: NetBox is accessible only from the server itself, and externally only through the reverse proxy.
  • ALLOWED_HOSTS: NetBox responds only to requests for your domain. Replace netbox.example.com with your domain. The built-in health check needs localhost.

Pull the images and start the stack:

Code
docker compose pull
docker compose up -d
docker compose ps

On first startup, NetBox creates the database. This takes a few minutes. NetBox is ready once docker compose ps shows the netbox container as healthy. Then create your admin account. The command prompts you for a username, email address, and password:

Code
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser

First Visit

First, set up the reverse proxy in the next section. Then open https://netbox.example.com and sign in with the account you just created. NetBox doesn’t display any data until you sign in; this is the default setting in NetBox Docker.

To quickly test NetBox first without exposing the port externally, use an SSH tunnel from your PC:

Code
ssh -L 8000:127.0.0.1:8000 root@SERVER_IP

Then open http://localhost:8000 in your browser. This works because localhost is included in ALLOWED_HOSTS.

HTTPS Access Through a Reverse Proxy

To access NetBox externally, put a reverse proxy with a valid certificate in front of it. For the basics, see Setting Up a Reverse Proxy with nginx and Creating an SSL Certificate (Let's Encrypt). Here’s a server block for nginx:

Code
server {
    listen 80;
    server_name netbox.example.com;
    client_max_body_size 25m;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Then get the certificate with certbot --nginx -d netbox.example.com. Certbot adds HTTPS and HTTP redirection to the block. NetBox reads the X-Forwarded-Proto header to detect that the connection is using HTTPS. If it’s missing, login fails with a CSRF error. client_max_body_size allows larger uploads, such as photos of racks or devices.

For more tips on securing your server, see Linux Security Tips.

Back Up Your Data

The most important data is the PostgreSQL database, which contains all objects, users, and settings. Uploaded images and attachments are in the media folder. Back up both using the commands in the NetBox Docker documentation:

Code
cd /opt/netbox
docker compose exec -T postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > netbox-db-$(date +%F).sql.gz
docker compose exec -T netbox tar czf - -C /opt/netbox/netbox/media . > netbox-media-$(date +%F).tar.gz

Also back up the env/ folder and the docker-compose.override.yml file. Without the SECRET_KEY and pepper from env/netbox.env, existing API tokens won’t work after a restore. Don’t keep the backup only on the VPS itself.

Update NetBox

Back up the database first, then read the NetBox Docker release notes and the NetBox release notes. Then fetch the latest project files and images and restart the stack:

Code
cd /opt/netbox
git pull -p origin release
docker compose pull
docker compose up -d

When it starts, NetBox updates the database for the new version. Your docker-compose.override.yml file remains in place. If git pull stops because the project has changed one of the files in env/, copy your values first (cp -r env env.bak), reset the files with git checkout env/, fetch the update, and add your passwords, SECRET_KEY, and pepper again. The installed version is shown in the bottom-left corner of the NetBox menu.

Info: PostgreSQL major version

If an update to NetBox Docker switches to a new PostgreSQL major version, the database won’t start automatically with the old data. You’ll need to export the data with pg_dump and import it into the new version. The steps are in the NetBox Docker troubleshooting guide.

Getting Started with NetBox

After setup, NetBox is empty. Objects build on one another, so it’s helpful to follow a set order.

Create a Site and Rack

  1. In the menu on the left, go to Organization > Sites and click Add. Enter a Name, such as Data Center, and save with Create.
  2. Create a rack under Racks > Racks and select your site under Site.
  3. Before you can add devices, NetBox needs a manufacturer (Devices > Manufacturers), a device type (Devices > Device Types), and a role (Devices > Device Roles), such as Server or Switch.
  4. Add the device under Devices > Devices and assign it to a site, rack, and rack unit.
Tip: Don’t enter device types manually

Ready-made templates with all interfaces are available for many servers and switches in the Device Type Library. Add a device type’s YAML content under Device Types > Import.

Manage IP Addresses

  1. Add your network under IPAM > Prefixes, for example, 192.168.10.0/24.
  2. Open the prefix. The IP Addresses tab shows which addresses are assigned and which are available.
  3. Assign an address to a device interface. This tells NetBox which device has which IP address.

You can import larger inventories as CSV, JSON, or YAML using Import. The button is available in every object list.

API Access

Scripts and tools can read and modify all objects through the REST API at /api/ and GraphQL at /graphql/. You’ll need an API token: click your username in the top-right corner, open API Tokens, and click Add a Token. If needed, choose whether the token can write (Write enabled), when it expires (Expires), and which addresses can use it (Allowed IPs), then click Create. NetBox only shows the value once, so copy it immediately.

Since NetBox 4.5, there are two token versions, which you select in the Version field. New v2 tokens start with nbt_ and are sent with Authorization: Bearer. They require a pepper in the configuration; for the manual installation above, this is API_TOKEN_PEPPER_1:

Code
curl -H "Authorization: Bearer nbt_SCHLUESSEL.TOKEN" -H "Accept: application/json" https://netbox.example.com/api/dcim/sites/
Info: API tokens in the One-Click App

The One-Click App currently doesn’t set a pepper. If you select v2, NetBox displays “Unable to save v2 tokens: API_TOKEN_PEPPERS is not defined”. In that case, select v1 in Version. A v1 token is sent with Authorization: Token TOKEN. NetBox considers v1 tokens deprecated and plans to remove them in NetBox 5.0.

Limitations

  • No monitoring or discovery: NetBox stores what you enter or write through the API. It doesn’t query devices or detect changes. You’ll need your own scripts or additional tools for automatic discovery.
  • Maintaining the data takes work: NetBox is only as good as its data. Decide who is responsible for maintaining what, and use the change log under Operations > Change Log.
  • Plugins: Many extensions are available as plugins. They must be built into the image. You can do this with a custom image for a manual installation, but not with the One-Click App.

Conclusion

You’ve set up NetBox on your VPS, signed in as an admin, and learned how to create sites, racks, devices, and IP addresses and access them through the API. You now have a central record of your infrastructure that both people and tools can use.

Prefer not to handle Docker yourself? Use the easy One-Click App option described above under “The Easy Way: NetBox as a One-Click App.”

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the quickest option: after the first startup, NetBox runs with PostgreSQL, cache, and a worker over HTTPS on your domain. The admin account and all passwords are generated automatically, and you can install updates from the dashboard. The manual installation with NetBox Docker is a good choice if you don’t use One-Click Apps on your server, want to run NetBox behind your own reverse proxy, build plugins into a custom image, or manage the configuration yourself.
For the One-Click App, the username is admin. Find the password on the app card by clicking the gear icon and going to App Environment > Automatically Generated Values. The password is stored in SERVICE_PASSWORD_NETBOXADMIN. For a manual installation, create the account yourself with createsuperuser.
On first startup, NetBox runs several hundred database migrations. In our test, this took just over ten minutes. Until they’re finished, the app card shows an error status and the worker restarts several times. Wait without redeploying the app. NetBox is ready once the logs show Initialisation is done.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.