502 while adding or editing a site #3058

Closed
opened 2025-12-29 18:25:13 +01:00 by adam · 4 comments
Owner

Originally created by @Alkanov on GitHub (Dec 10, 2019).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.6.7

Steps to Reproduce

  1. Fresh install on a fresh Ubuntu 18.04.3 LTS + nginx
  2. Logged in as root user
  3. Try to add a new site
  4. 502 Bad Gateway

Workaround

You can add new sites via Import

Expected Behavior

Be able to add a new site.

Observed Behavior

I get a 502 error

Nginx configuration

server {
    listen 80;

    server_name localhost;

    client_max_body_size 25m;

    location /static/ {
        alias /opt/netbox/netbox/static/;
    }

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
}

Logs

2019/12/10 15:54:55 [error] 10372#10372: *9 upstream prematurely closed connection while reading response header from upstream, client: 10.0.2.2, server: localhost, request: "GET /dcim/sites/add/ HTTP/1.1", upstream: "http://127.0.0.1:8001/dcim/sites/add/", host: "127.0.0.1:8000", referrer: "http://127.0.0.1:8000/dcim/sites/"

The same happens when trying to edit a site

2019/12/10 15:49:03 [error] 10372#10372: *1 upstream prematurely closed connection while reading response header from upstream, client: 10.0.2.2, server: localhost, request: "GET /dcim/sites/GBE/edit/ HTTP/1.1", upstream: "http://127.0.0.1:8001/dcim/sites/GBE/edit/", host: "127.0.0.1:8000", referrer: "http://127.0.0.1:8000/dcim/sites/GBE/"

Originally created by @Alkanov on GitHub (Dec 10, 2019). ### Environment * Python version: 3.6.9 * NetBox version: 2.6.7 ### Steps to Reproduce 1. Fresh install on a fresh Ubuntu 18.04.3 LTS + nginx 2. Logged in as root user 3. Try to add a new site 4. 502 Bad Gateway ### Workaround You can add new sites via Import ### Expected Behavior Be able to add a new site. <!-- What happened instead? --> ### Observed Behavior I get a 502 error ### Nginx configuration ``` server { listen 80; server_name localhost; client_max_body_size 25m; location /static/ { alias /opt/netbox/netbox/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } ``` ### Logs ### > 2019/12/10 15:54:55 [error] 10372#10372: *9 upstream prematurely closed connection while reading response header from upstream, client: 10.0.2.2, server: localhost, request: "GET /dcim/sites/add/ HTTP/1.1", upstream: "http://127.0.0.1:8001/dcim/sites/add/", host: "127.0.0.1:8000", referrer: "http://127.0.0.1:8000/dcim/sites/" The same happens when trying to edit a site > 2019/12/10 15:49:03 [error] 10372#10372: *1 upstream prematurely closed connection while reading response header from upstream, client: 10.0.2.2, server: localhost, request: "GET /dcim/sites/GBE/edit/ HTTP/1.1", upstream: "http://127.0.0.1:8001/dcim/sites/GBE/edit/", host: "127.0.0.1:8000", referrer: "http://127.0.0.1:8000/dcim/sites/GBE/"
adam closed this issue 2025-12-29 18:25:13 +01:00
Author
Owner

@hSaria commented on GitHub (Dec 10, 2019):

Can you include the gunicorn config?

@hSaria commented on GitHub (Dec 10, 2019): Can you include the gunicorn config?
Author
Owner

@jeremystretch commented on GitHub (Dec 10, 2019):

Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided here. For general discussion, questions, or assistance with installation issues, please post to our mailing list instead.

@jeremystretch commented on GitHub (Dec 10, 2019): Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided [here](https://github.com/digitalocean/netbox/issues/new/choose). For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) instead.
Author
Owner

@Alkanov commented on GitHub (Dec 11, 2019):

Hi @hSaria here is my gunicorn config as per readthedocs.io guide

command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = '127.0.0.1:8001'
workers = 3
user = 'www-data'
max_requests = 5000
max_requests_jitter = 500

I understand this could not be a direct bug with Netbox @jeremystretch but if I can do literally everything else except adding sites via the "add site" button or edit sites added via import do you think the problem could be related to the installation method(which it is also provided by your docs) or even Layer 8?

BTW: I used the template in https://github.com/digitalocean/netbox/issues/new/choose

@Alkanov commented on GitHub (Dec 11, 2019): Hi @hSaria here is my gunicorn config as per readthedocs.io guide ``` command = '/usr/bin/gunicorn' pythonpath = '/opt/netbox/netbox' bind = '127.0.0.1:8001' workers = 3 user = 'www-data' max_requests = 5000 max_requests_jitter = 500 ``` I understand this could not be a direct bug with Netbox @jeremystretch but if I can do literally everything else except adding sites via the "add site" button or edit sites added via import do you think the problem could be related to the installation method(which it is also provided by your docs) or even Layer 8? BTW: I used the template in https://github.com/digitalocean/netbox/issues/new/choose
Author
Owner

@Alkanov commented on GitHub (Dec 11, 2019):

Adding timeout to gunicorn did the trick

timeout = 60
@Alkanov commented on GitHub (Dec 11, 2019): Adding timeout to gunicorn did the trick ``` timeout = 60 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3058