Can't add a new vlan #11606

Closed
opened 2025-12-29 21:47:32 +01:00 by adam · 8 comments
Owner

Originally created by @TheGuardianLight on GitHub (Sep 12, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.4.0

Python Version

3.10

Steps to Reproduce

  1. Try to create a new VLAN on Netbox

Expected Behavior

To create a new vlan withour error

Observed Behavior

Netbox can't add a new VLAN, even if the one that I try to add don't exist into the database. The identifier of the VLAN don't already exist too.

Netbox don't provide any logs. The only logs that I have is on my navigator console with an error 500.

Image
Originally created by @TheGuardianLight on GitHub (Sep 12, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.4.0 ### Python Version 3.10 ### Steps to Reproduce 1. Try to create a new VLAN on Netbox ### Expected Behavior To create a new vlan withour error ### Observed Behavior Netbox can't add a new VLAN, even if the one that I try to add don't exist into the database. The identifier of the VLAN don't already exist too. Netbox don't provide any logs. The only logs that I have is on my navigator console with an error 500. <img width="662" height="124" alt="Image" src="https://github.com/user-attachments/assets/a30b0994-a6f7-4abc-be3b-1ed89ccfd9c7" />
adam added the netbox label 2025-12-29 21:47:32 +01:00
adam closed this issue 2025-12-29 21:47:33 +01:00
Author
Owner

@jnovinger commented on GitHub (Sep 12, 2025):

@TheGuardianLight , I can't reproduce this with the steps to reproduce that you've included. We need more details in order to reproduce this.

@jnovinger commented on GitHub (Sep 12, 2025): @TheGuardianLight , I can't reproduce this with the steps to reproduce that you've included. We need more details in order to reproduce this.
Author
Owner

@TheGuardianLight commented on GitHub (Sep 15, 2025):

I made a video of my issue if it can help you :

https://github.com/user-attachments/assets/dc9ec792-9687-4187-b7f7-724935bf3eca

@TheGuardianLight commented on GitHub (Sep 15, 2025): I made a video of my issue if it can help you : https://github.com/user-attachments/assets/dc9ec792-9687-4187-b7f7-724935bf3eca
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2025):

@TheGuardianLight The video you've posted doesn't provide any further information to reproduce the bug.

@jeremystretch commented on GitHub (Sep 15, 2025): @TheGuardianLight The video you've posted doesn't provide any further information to reproduce the bug.
Author
Owner

@TheGuardianLight commented on GitHub (Sep 15, 2025):

Well, I can't say more that I already have and know... Netbox don't provide me any logs for this issue.

@TheGuardianLight commented on GitHub (Sep 15, 2025): Well, I can't say more that I already have and know... Netbox don't provide me any logs for this issue.
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2025):

NetBox absolutely provides logs, as does your HTTP server. I'd suggest you investigate the apparent 500 error being returned.

@jeremystretch commented on GitHub (Sep 15, 2025): NetBox absolutely provides logs, as does your HTTP server. I'd suggest you investigate the apparent 500 error being returned.
Author
Owner

@TheGuardianLight commented on GitHub (Sep 15, 2025):

Alright I will look more further about this error 500.

@TheGuardianLight commented on GitHub (Sep 15, 2025): Alright I will look more further about this error 500.
Author
Owner

@TheGuardianLight commented on GitHub (Sep 16, 2025):

Alright @jeremystretch and @jnovinger I found the issue :

Internal Server Error: /ipam/vlans/add/
Traceback (most recent call last):
  File "/opt/netbox/netbox/netbox/middleware.py", line 128, in __call__
    username = request.META[self.header]
KeyError: 'HTTP_REMOTE_USER'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "ipam_vlan_pkey"
DETAIL:  Key (id)=(179) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 105, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 192, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 144, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 45, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 144, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 297, in post
    obj = form.save()
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/forms/models.py", line 554, in save
    self.instance.save()
  File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save
    super().save(*args, **kwargs)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1008, in save_base
    updated = self._save_table(
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1169, in _save_table
    results = self._do_insert(
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1210, in _do_insert
    return manager._insert(
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1868, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
    cursor.execute(sql, params)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
  File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "ipam_vlan_pkey"
DETAIL:  Key (id)=(179) already exists.

It's seem that he try to add the VLAN under an ID that's already used.

@TheGuardianLight commented on GitHub (Sep 16, 2025): Alright @jeremystretch and @jnovinger I found the issue : ``` Internal Server Error: /ipam/vlans/add/ Traceback (most recent call last): File "/opt/netbox/netbox/netbox/middleware.py", line 128, in __call__ username = request.META[self.header] KeyError: 'HTTP_REMOTE_USER' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 97, in execute raise ex.with_traceback(None) psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "ipam_vlan_pkey" DETAIL: Key (id)=(179) already exists. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 105, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 192, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 144, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 45, in dispatch return super().dispatch(request, *args, **kwargs) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 144, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 297, in post obj = form.save() File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/forms/models.py", line 554, in save self.instance.save() File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save super().save(*args, **kwargs) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 902, in save self.save_base( File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1008, in save_base updated = self._save_table( File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1169, in _save_table results = self._do_insert( File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1210, in _do_insert return manager._insert( File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1868, in _insert return query.get_compiler(using=using).execute_sql(returning_fields) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql cursor.execute(sql, params) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in execute return self._execute_with_wrappers( File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers return executor(sql, params, many, context) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 100, in _execute with self.db.wrap_database_errors: File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) File "/data/netbox-4.4.0/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 97, in execute raise ex.with_traceback(None) django.db.utils.IntegrityError: duplicate key value violates unique constraint "ipam_vlan_pkey" DETAIL: Key (id)=(179) already exists. ``` It's seem that he try to add the VLAN under an ID that's already used.
Author
Owner

@TheGuardianLight commented on GitHub (Sep 16, 2025):

To solve the issue, I had to reset the ID sequence of the ipam_vlan table in the PostgreSQL database with the command :

ALTER SEQUENCE ipam_vlan_id_seq RESTART WITH next_id;

Where next_id is the next usable primary ID.

@TheGuardianLight commented on GitHub (Sep 16, 2025): To solve the issue, I had to reset the ID sequence of the `ipam_vlan` table in the PostgreSQL database with the command : ```sql ALTER SEQUENCE ipam_vlan_id_seq RESTART WITH next_id; ``` Where `next_id` is the next usable primary ID.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11606