502 Bad Gateway

gpetrom

New Member
May 6, 2021
20
0
1
47
Hi everyone

I have installed djangopbx following the directions from the video

I have not seen any errors during install but when i am trying to open the page i am getting the following error in nginx error.log
[crit] 638#638: *47 connect() to unix:///home/django-pbx/pbx/django-pbx.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.1.103, server: djangoipx, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///home/django-pbx/pbx/django-pbx.sock:", host: "djangopbx.testserver.lan"

Any ideas what is happening?

Thanks in advanced
 

jcre

New Member
Feb 5, 2024
4
0
1
36
As a good first step it's worth rebooting just to make sure all services are started and running as the right users, have you rebooted since the install? Otherwise you could try running systemctl uwsgi restart
 

gpetrom

New Member
May 6, 2021
20
0
1
47
Yes i have rebooted the server but still i have the same problem
nginx freeswitch and uwsgi is starting without errors
 

jcre

New Member
Feb 5, 2024
4
0
1
36
what are the ownership permissions on django-pbx.sock? Also in /etc/nginx/nginx.conf is the first line "user www-data;"?
 

gpetrom

New Member
May 6, 2021
20
0
1
47
Thanks that was the problem
when i changed the ownership
chown www-data:django-pbx /home/django-pbx/pbx/django-pbx.sock
i was able to open the page
I have changed the ownership on django-pbx.sock because nginx is starting with django-pbx user. I hope this is the correct solution.
 

jcre

New Member
Feb 5, 2024
4
0
1
36
Is this on Debian Bookworm? Looks like it might be a bug in the installer, so I want to try and replicate it
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,415
376
83
Probably need to did into this a little deeper. There should be no problem with Nginx running as the www-data user. uWSGI creates the socket with user django-pbx and group www-data so there should be no permissions issue.

As @jcre says we need to confirm the operating system, and if it is a standard Debian install as opposed to a cloud based offering.

There are some cloud installations that change the permissions on the user directory at boot time from 755 to 700, the socket will not work with these strict permissions. Although the installer initially sets the permissions to 755 other processes can change them.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,415
376
83
Having said the above, I notice that there is a line in the installer that changes the Nginx user:

Code:
sed -i "s/www-data/django-pbx/g" /etc/nginx/nginx.conf

I looked at a couple of working test installs done last week and they all have www-data as the Nginx user in the nginx.conf file. I ran the sed command and it does correctly edit the file. So either it's not working in the installer or something is changing it back...
 

gpetrom

New Member
May 6, 2021
20
0
1
47
I have tried it with standard net install debian bookworm iso
I can confirm that in the nginx.conf file the user was django-pbx and not www-data.
django-pbx.sock had group www-data and root user not django-pbx