Can’t access backend from diferent localhost

I have installed trytond 8.0.2

Access from localhost is ok but when I try from another address it gives a 401 error.
I tried with sao and rpc client

conf

[web]
listen = 0.0.0.0:4548
cors =
    http://192.168.1.111
    http://localhost
    *
root = /opt/venv/Tryton8/sao

logs

INFO werkzeug 127.0.0.1 - - [06/May/2026 20:41:57] "POST /mp/rpc/ HTTP/1.1" 200 -
INFO werkzeug 127.0.0.1 - - [06/May/2026 20:42:05] "POST /mp/rpc/ HTTP/1.1" 200 -
INFO werkzeug 127.0.0.1 - - [06/May/2026 20:44:21] "POST /mp/bus HTTP/1.1" 200 -
ERROR trytond.security session failed for '1' from '192.168.1.111' on database 'mp'
INFO werkzeug 192.168.1.111 - - [06/May/2026 20:44:59] "POST /mp/rpc/ HTTP/1.1" 401 -

How do you deploy your system?, I would like to help you but is the first time that I see this error message. I saw that you have cors, the 0.0.0.0 this must be work.

401 is an usal error of credentials.

I have reproduce the error using de RPC call. Could you share your code for RPC client?

image

this code works for me:

In [65]: import requests
    ...: import json
In [73]: HOST = '127.0.0.1'
    ...: PORT = '8090'
    ...: DATABASE = 'tryton'
    ...: USER = 'admin'
    ...: PASSWD = 'S0p0rt3f1n4l*'
    ...: 
    ...: url = f"http://{HOST}:{PORT}/{DATABASE}/"
    ...: 
    ...: # 1. Login
    ...: payload = json.dumps({
    ...:     'jsonrpc': "2.0",
    ...:     'method': 'common.db.login',
    ...:     'params': [USER, {'password': PASSWD}],
    ...:     'id': 1
    ...: })

In [70]: response = requests.post(url, data=payload, headers={'Content-Type': 'application/json'})

I deploy with virtualenv ./.venv/bin/trytond -c trytond.conf --dev

with httpx.Client(timeout=5.0, headers=headers) as client:
  body = {“id”:1,“method”:“model.sale.sale.create”,“params”:[payload,{}]}
  r = client.post(“http://192.168.1.111:4548/mp/rpc/”, json=body)

if I change the url to localhost it works but with this while the login responds correctly, at the rpc the response is empty (the same on sao)

Since the usage of cookie to store the session in sao, it does not work without a secure connection except for localhost. See tryton_session cookie is rejected (#14813) · Issues · Tryton / Tryton · GitLab

Is this something that will be fixed in the future or do I need to set some parameter in the config ?

[session]
secure = False

For development use localhost and otherwise secure the connection.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.