NetBox is an open source web application designed to help manage and document computer networks. Initially conceived by the network engineering team at DigitalOcean,

“But godliness with contentment is great gain”

Updated Article for Ubuntu 18.04:

How to Install NetBox on Ubuntu 18.04 LTS

For CentOS users use:

How to Install NetBox on CentOS 7 with Apache and Supervisord

Step One

Initial set-up of Ubuntu server.

This is in case you have a new installation in your premise
Create a new sudo user

$ sudo useradd tech

Add superuser privileges to your new user to enable the user tun administrative tasks without using root
The best way to do this on Ubuntu is by adding the new user to the “sudo” group which has administrative privileges by default

$ sudo usermod -aG sudo tech

Step Two

Installation of PostgreSQL

Let us update the system and install PostgreSQL

$ sudo apt-get update
$ sudo apt-get install -y postgresql libpq-dev

Check if PostgreSQL is running

[email protected]:~$ systemctl status postgresql
WARNING: terminal is not fully functional
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor 
   Active: active (exited) since Wed 2018-06-27 04:39:32 EDT; 26min ago
 Main PID: 11811 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/postgresql.service

Jun 27 04:39:32 pri systemd[1]: Starting PostgreSQL RDBMS...
Jun 27 04:39:32 pri systemd[1]: Started PostgreSQL RDBMS.
Jun 27 04:39:42 pri systemd[1]: Started PostgreSQL RDBMS.
lines 1-9/9 (END)

Step Three

Creation of a database and user for NetBox and grant all privileges to the user. The user is netbox and the user is netbox as well. Use your own password:

[email protected]:~$ sudo -u postgres psql


password for tech: psql (9.5.13) Type “help” for help. postgres=# CREATE DATABASE netbox; CREATE DATABASE postgres=# CREATE USER netbox WITH PASSWORD ‘example12’; CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox; GRANT postgres=# \q

Try logging into the database t ensure that it is working. Just enter the following command and pass it the password you had defined. For me, it is example12. A netbox prompt will ensue if successful.

[email protected]:~$ psql -U netbox -W -h localhost netbox
Password for user netbox: 
psql (9.5.13)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.


Step Four

Installation of NetBox Application.
First, we have to install the dependencies and packages including python3

$ sudo apt-get install -y python3 python3-dev python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev zlib1g-dev
$ sudo easy_install3 pip

After this, let us download NetBox from git and install it. Just in case git is not already installed, please install it.
Install git

[email protected]:~$ sudo apt-get install -y git                                                                                                               
Reading package lists... Done
Building dependency tree       
Reading state information... Done

Create the base NetBox directory

$ sudo mkdir -p /opt/netbox/
$ cd /opt/netbox/

After this, just cloneNetBox GitHub repository into the base folder we have created. Do not forget the trailing dot.

$ git clone -b master .

Next, change the ownership of /opt/netbox/netbox/media/ directory to your user.

[email protected]:/opt/netbox$ sudo chown -R tech:tech /opt/netbox/netbox/media/
[email protected]:/opt/netbox$ ls                                           mkdocs.yml  
docs             netbox                requirements.txt
LICENSE.txt      old_requirements.txt  scripts

Python package Installation
Let us next install python packages in the requiements.txt file using pip. The packages are

[email protected]:/opt/netbox$ cat requirements.txt 
Django>=1.11,<2.0 django-cors-headers>=2.1.0
$ pip3 install -r requirements.txt
You will see messages like below. Let them finish..
Collecting Django<2.0,>=1.11 (from -r requirements.txt (line 1))
  Downloading (6.9MB)

Step Five

Configure NetBox
After the completion of the python packages, the next step is to configure NetBox. The example configuration file is in /opt/netbox/netbox/netbox directory so change into the directory and make a copy of it

$ cd /opt/netbox/netbox/netbox
$ cp

Inside the file, edit the following parts as shwn below:

ALLOWED_HOSTS= [‘ip or hostname of the server’]

# Example: ALLOWED_HOSTS = ['', 'netbox.internal.local']

# PostgreSQL database configuration.
    'NAME': 'netbox',         # Database name
    'USER': 'netbox',               # PostgreSQL username
    'PASSWORD': 'example12',           # PostgreSQL password
    'HOST': 'localhost',      # Database server
    'PORT': '',               # Database port (leave blank for default)

# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
# symbols. NetBox will not run without this defined. For more information, see
SECRET_KEY = '[email protected]=%62B1-sCexf*secret*rdGzH^lQbcMNVo4Apu9Jvy7Y_F*w)3TthSP+'

For the secret key, just navigate to /opt/netbox/netbox and use the script to generate it for you in the following way.

$ cd /opt/netbox/netbox
$ ./

The secret key will be generated and should be kept secret. Paste it in the SECRET_KEY part of the conf file.
In case the database is on a different server, please place its IP Address in the HOST part of the DATABASE code block. The username and password are the nes you provided when installing the postgreSQL.
Because Netbox uses a datbase to run, a schema needs to be installed. To have that accomplished, just do the following:

$ cd /opt/netbox/netbox/
$ python3 migrate
[email protected]:/opt/netbox/netbox$ sudo python3 migrate
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, tenancy, users, virtualization
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying tenancy.0001_initial... OK
  Applying dcim.0001_initial... OK

Step Six

User Creation and collection of static files for the webgui.
Since NetBox does not come with default users, we will have to create one user for the purposes of logging into the system when we launch it.

[email protected]:/opt/netbox/netbox$ sudo python3 create superuser
Unknown command: 'create'
Type ' help' for usage.
[email protected]:/opt/netbox/netbox$ sudo python3 createsuperuser 
Username (leave blank to use 'root'): tech
Email address: 
Password (again): 
Superuser created successfully.
[email protected]:/opt/netbox/netbox$ sudo python3 collectstatic --no-input
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/js/bootstrap.min.js'
Copying '/opt/netbox/netbox/project-static/bootstrap-3.3.7-dist/js/npm.js
279 static files copied to '/opt/netbox/netbox/static'.

NetBox provides initial data for you if you would wish to begin using it right away. In case you would wish to start everything on your own, you can skip this step

[email protected]:/opt/netbox/netbox$ sudo python3 loaddata initial_data
Installed 53 object(s) from 5 fixture(s)

Step Seven

Testing our fresh NetBox
This installtion is a test environment and I will be covering the entire set up later. Cruise around the test environment and see if it befits your needs. The test environment runs within a virtual environment as follows.

[email protected]:/opt/netbox/netbox$ sudo python3 runserver --insecure
Performing system checks...

System check identified no issues (0 silenced).
June 28, 2018 - 07:51:54
Django version 1.11.13, using settings 'netbox.settings'
Starting development server at
Quit the server with CONTROL-C.
[28/Jun/2018 07:52:04] "GET /login/?next=/ HTTP/1.1" 200 14516
[28/Jun/2018 07:53:25] "POST /login/ HTTP/1.1" 302 0
[28/Jun/2018 07:53:26] "GET / HTTP/1.1" 200 37460

Now navigate to your browser and type in the IP address of your server plus the port number for example:

Cheers if it worked and thank you for visiting the site.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here