Netbox Server Debug set to False Erroring #1214

Closed
opened 2025-12-29 16:30:06 +01:00 by adam · 2 comments
Owner

Originally created by @jpc2350 on GitHub (Sep 6, 2017).

Issue type

[ X ] Bug report

Environment

  • Python version: 3.5.2
  • NetBox version: 2.1.4
    Ubuntu 16.04
    Saltstack 2016.11.7 (Carbon)
    PostgreSQL 9.6
    Nginx 1.10.3

Description

Running a clone from the master repository, installing postgres and nginx as required with gunicorn and supervisor. Supervisor is up and running, and running Gunicorn (as per the documentation here:
https://netbox.readthedocs.io/en/latest/installation/web-server/ )

With the Configuration variable DEBUG set to True in configuration.py, the Netbox works, producing the home screen, with a Django Debug tool bar ( as expected for debug)

With DEBUG set to False in configuration.py, I should expect the above without the Django Debug toolbar, however I get the following when browsing to the web page:
screen shot 2017-09-06 at 14 13 47 2

And in the logs (In Custom Logging, I've got a debug log to file setup)

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/template/base.py", line 882, in _resolve_lookup
    current = current[bit]
TypeError: 'SQLPanel' object is not subscriptable

The following is the whole extracted error:

netbox_debug_error_debug_log.txt

Originally created by @jpc2350 on GitHub (Sep 6, 2017). ### Issue type [ X ] Bug report <!-- Reporting unexpected or erroneous behavior --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) --> ### Environment * Python version: 3.5.2 * NetBox version: 2.1.4 Ubuntu 16.04 Saltstack 2016.11.7 (Carbon) PostgreSQL 9.6 Nginx 1.10.3 <!-- BUG REPORTS must include: * A list of the steps needed to reproduce the bug * A description of the expected behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description Running a clone from the master repository, installing postgres and nginx as required with gunicorn and supervisor. Supervisor is up and running, and running Gunicorn (as per the documentation here: https://netbox.readthedocs.io/en/latest/installation/web-server/ ) With the Configuration variable DEBUG set to True in configuration.py, the Netbox works, producing the home screen, with a Django Debug tool bar ( as expected for debug) With DEBUG set to False in configuration.py, I should expect the above without the Django Debug toolbar, however I get the following when browsing to the web page: ![screen shot 2017-09-06 at 14 13 47 2](https://user-images.githubusercontent.com/23191993/30113775-bbdd0b86-930d-11e7-9658-7a8db5de6682.png) And in the logs (In Custom Logging, I've got a debug log to file setup) ```Exception while resolving variable 'starts_trans' in template 'debug_toolbar/panels/sql.html'. Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/django/template/base.py", line 882, in _resolve_lookup current = current[bit] TypeError: 'SQLPanel' object is not subscriptable ``` The following is the whole extracted error: [netbox_debug_error_debug_log.txt](https://github.com/digitalocean/netbox/files/1281174/netbox_debug_error_debug_log.txt)
adam closed this issue 2025-12-29 16:30:06 +01:00
Author
Owner

@jpc2350 commented on GitHub (Sep 7, 2017):

The problem was actually occurring with ALLOWED_HOSTS = None (A Saltstack issue was not populating this in the configuration file). However, An odd problem to get only when DEBUG = False.

Setting DEBUG = True meant that I had access to Netbox, with ALLOWED_HOSTS = None

@jpc2350 commented on GitHub (Sep 7, 2017): The problem was actually occurring with ALLOWED_HOSTS = None (A Saltstack issue was not populating this in the configuration file). However, An odd problem to get only when DEBUG = False. Setting DEBUG = True meant that I had access to Netbox, with ALLOWED_HOSTS = None
Author
Owner

@jeremystretch commented on GitHub (Sep 11, 2017):

ALLOWED_HOSTS must be defined as a list of hostnames as specified in the docs. It is not evaluated when DEBUG is true because debugging disables request host validation.

@jeremystretch commented on GitHub (Sep 11, 2017): `ALLOWED_HOSTS` must be defined as a list of hostnames as specified [in the docs](http://netbox.readthedocs.io/en/stable/configuration/mandatory-settings/#allowed_hosts). It is not evaluated when `DEBUG` is true because debugging disables request host validation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1214