Error when accessing Odoo on Browser

Hello

I need help with below error when trying to access Odoo on the browser. All other services are running as expected

I see this entry in the log file /var/log/odoo/odoo.log

OSError: [Errno 13] Permission denied: '/var/lib/odoo'
2023-03-09 14:45:57,214 23307 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 181, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/service/server.py", line 307, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/service/wsgi_server.py", line 186, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/service/wsgi_server.py", line 172, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/http.py", line 1326, in __call__
    return self.dispatch(environ, start_response)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/http.py", line 1300, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/site-packages/werkzeug/wsgi.py", line 599, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/http.py", line 1463, in dispatch
    explicit_session = self.setup_session(httprequest)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/http.py", line 1360, in setup_session
    session_gc(self.session_store)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/tools/func.py", line 23, in __get__
    value = self.fget(obj)
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/http.py", line 1311, in session_store
    path = odoo.tools.config.session_dir
  File "/usr/lib/python2.7/site-packages/odoo-10.0.post20190619-py2.7.egg/odoo/tools/config.py", line 604, in session_dir
    os.makedirs(d, 0700)
  File "/usr/lib64/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/var/lib/odoo'

I tried to troubleshoot the Permission Denied error but when I open the directory /var/lib/ but there is no odoo file

OSError: [Errno 13] Permission denied: '/var/lib/odoo'

systemctl status odoo shows below output

odoo.service - LSB: Launches the Odoo server.
   Loaded: loaded (/etc/rc.d/init.d/odoo; bad; vendor preset: disabled)
   Active: active (running) since Thu 2023-03-09 16:43:26 CAT; 24min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 23055 ExecStop=/etc/rc.d/init.d/odoo stop (code=exited, status=0/SUCCESS)
  Process: 23296 ExecStart=/etc/rc.d/init.d/odoo start (code=exited, status=0/SUCCESS)
 Main PID: 23307 (odoo)
   CGroup: /system.slice/odoo.service
           └─23307 /bin/python /usr/bin/odoo -c /etc/odoo.conf --update all --database odoo --without-demo all --pidfile=/var/run/odoo/odoo-server...

Mar 09 16:43:25 dev-svr systemd[1]: Starting LSB: Launches the Odoo server....
Mar 09 16:43:25 dev-svr odoo[23296]: mkdir: cannot create directory ‘odoo’: File exists
Mar 09 16:43:25 dev-svr runuser[23305]: pam_unix(runuser:session): session opened for user odoo by (uid=0)
Mar 09 16:43:25 dev-svr systemd[1]: Can't open PID file /var/run/odoo/odoo-server.pid (yet?) after start: No such file or directory
Mar 09 16:43:25 dev-svr odoo[23296]: Starting Odoo Server Daemon (odoo-server): [  OK  ]
Mar 09 16:43:26 dev-svr systemd[1]: Started LSB: Launches the Odoo server..
Mar 09 16:45:21 dev-svr odoo[23296]: Warn: Can't find .pfb for face 'Times-Roman'

likely to be a permission issue. Can you check the permission to /var/lib/ directory? also check the odoo service file and see if the the user and group have relevant permissions.

you can identify the service file by running commands like

systemctl show -P FragmentPath odoo.service

Thanks for your response @angshuonline

The /var/lib/ directory has 755 permissions

drwxr-xr-x. 33 root root 4096 Mar 9 09:58 lib

The command brings this output

FragmentPath=/run/systemd/generator.late/odoo.service

…and the service file has 644 permissions

-rw-r--r-- 1 root root 806 Mar 10 11:48 odoo.service

hi @tapologo you need to open the service file in the vi editor or so, and check the user, group … if the servicefile has any execStart, then check the shell script permissions.

The user or group are not specified within the file

Here are the permissions of the Odoo script

/etc/rc.d/init.d/

lrwxrwxrwx 1 root root 24 Mar 10 11:32 odoo -> /opt/bahmni-erp/bin/odoo

/opt/bahmni-erp/bin/

-rwxr--r-- 1 odoo odoo 3574 Mar 29 2022 odoo

So I created the odoo directory manually in /var/lib/ and changed ownership to odoo and now I am able to open odoo in the browser

cd /var/lib && mkdir odoo

chown odoo:odoo -R odoo/