Can't be logged on different servers at the same time

I can’t be logged in into 2 different servers at the same time.

¿Is there any way to achieve this?

I have the server A and the server B, and I would like to compare some things between them. For instance, a workflow, but could be credentials, or executions, or any thing.

The point is that I log in server A, and open a workflow. Then I open another tab and enter the url for server B. A login is requested and I get in. Then I open a workflow form server B.

At this time I have 2 tabs in the browser, one with the server A and another with the server B, and this last tab is the active one.

Now come back to the first tab to check the server A and try to do something but nothing works and I have to refresh the page: a new login is requested!

I log into server A, do my stuff, and then click on the other tab, the one for the server B. I try to do something but nothing works until I refresh the page: a new login is requested!

Each time I change of tab (and server) a login is requested. It seems that the session data is shared between the servers in some way.

The objective is to have 2 o more servers logged in with session data (or whatever it is) related to each server and not to the client.

¿Is there any way to do it?

This happens from old versions (1.x) up to the current now (v1.24.1).

Thank you in advance!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @PabloRQ

Welcome to the community :partying_face:

I do this all the time, so something must be wrong with this server setup. please provide the info on both servers. and give us a bit more details on those servers if possible.

Hi @BramKn !

Thank you for your quick response.

Both servers run in a different hardware with the same docker compose (portainer) configuration:

version: '3.8'

volumes:
  db_data:
  main_data:

services:
  postgres:
    image: postgres:11
    restart: always
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_NON_ROOT_USER=${POSTGRES_NON_ROOT_USER}
      - POSTGRES_NON_ROOT_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
    volumes:
      - db_data:/var/lib/postgresql/data
      - ${N8N_LOCAL_FILES}/n8n-config/init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10

  main:
    image: docker.n8n.io/n8nio/n8n:${N8N_VERSION}
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
      - GENERIC_TIMEZONE=Europe/Madrid
      - TZ=Europe/Madrid
      - NODE_FUNCTION_ALLOW_EXTERNAL=*
      - N8N_PORT=5678
    ports:
      - 5678:5678
    links:
      - postgres
    volumes:
      - main_data:/home/node/.n8n
      - ${N8N_LOCAL_FILES}:/files
    depends_on:
      postgres:
        condition: service_healthy

Data (workflows and credentials) are different in each server.

Both servers are in local network or connected by SSH tunneling. No server has a public IP or domain name.

For the client, I’m using Ubuntu 23.10 and Firefox 121.0.1.

Any idea?

I also do this all the time with 3 different instances, When you access the instances are you using different urls / ips?

Good point @Jon. All are in localhost but in different ports.

2 of them are running in the local hardware and others are connected by SSH tunneling, which finally is a local port connected with a remote one.

Could be that the session is bound to the host but not host+port?

Hey @PabloRQ,

That could possibly be it.

Is it possibly to change this behavior?

I mean, to be able to stay logged in 2 o more different servers in localhost+port at the same time.

Hey @PabloRQ,

The problem is we use a cookie to store the auth token and the domain part of a cookie while at one point it did allow for a port it was not used by all browsers so there was a change to the RFC that dropped this as an option.

The best solution for this would be to add the services to your local hosts file so you could have…

127.0.0.1 n8n1
127.0.0.1 n8n2
127.0.0.1 n8n3

Then in your browser you can load http://n8n1 (or 2 / 3) and while they point back to localhost the domain is different and it should solve the problem.

2 Likes

That works!

1 Like

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