Image attachment issues, Netbox v2.9.9

612 views
Skip to first unread message

Matt Rogers

unread,
Feb 2, 2021, 7:01:34 PM2/2/21
to NetBox
This subject has been brought up before, but I and likely many others are still puzzled.

After attempting to attach an image, I am given a Server Error with the following text:

A file permission error was detected while processing this request. Common causes include the following:

Insufficient write permission to the media root - The configured media root is . Ensure that the user NetBox runs as has access to write files to all locations within this path.

The complete exception is provided below:

<class 'PermissionError'>
[Errno 13] Permission denied: '/opt/netbox/netbox/media/image-attachments/<image name>.png'

Python version: 3.6.9

NetBox version: 2.9.9 

I have tried changing permissions recursively on the /opt/netbox/netbox/media directory to 775 as suggested by one post but this does not work. Other fixes including changing the ownership of the directory. My Ubuntu 18.04.5 LTS VM only has one user configured (besides root). Root currently has permissions over that directory.

Which user of what module needs to be the owner for this error to be resolved? The Netbox database user, perhaps or something else? Looking for the principle--the idea behind this aspect. I know you don't know "what users I've configured" by name. You get the idea.

Great forum, and thanks in advance!

Brian Candler

unread,
Feb 3, 2021, 3:14:48 AM2/3/21
to NetBox
What user are you running the Netbox *application* as - that is, the gunicorn process?

If you've followed the default installation instructions then you'll have created a "netbox" user for this to run as:

That's the user that needs to own the media directory.

You're not running under docker are you, by any chance?

Matt Rogers

unread,
Feb 3, 2021, 10:36:23 AM2/3/21
to NetBox
Hello Brian, and thanks for responding so quickly. That is very helpful to know.
And no, I am not running under docker.
Thanks!

Matt Rogers

unread,
Feb 3, 2021, 11:17:25 AM2/3/21
to NetBox
Understanding that it's the gunicorn process made a world of difference and I am now able to upload images. Thanks so much!
I did the following based on your information:
chown --recursive www-data /opt/netbox/netbox/media

For anyone interested, my build contains a user called www-data that was instantiated during the supervisor setup:
nano /etc/supervisor/conf.d/netbox.conf
##enter the following in the conf file:

[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = www-data

[program:netbox-rqworker]
command = python3 /opt/netbox/netbox/manage.py rqworker
directory = /opt/netbox/netbox/
user = www-data
## save
Reply all
Reply to author
Forward
0 new messages