Very first workflow execution show "lost connection to the server"

Describe the problem/error/question

Accessing n8n is good, but execution shows error message.

What is the error message (if any)?

“Lost Connection to the server “

Please share your workflow

Nothing but Manual Click Node

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.16.1
  • Running n8n via Docker compose
  • Operating system: ubuntu 22.04
  • Docker Compose File is bellow
    and I already PortFowared 5678, 80, 443 ports to this machine in my router.
services:
  n8n:
    image: n8nio/n8n
    container_name: n8n-app
    networks:
      - n8n-network
    environment:
      - N8N_HOST=MyRouterDDNS.org       
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - N8N_SECURE_COOKIE=false
      - N8N_DEFAULT_LOCALE=kr
      - WEBHOOK_URL=https://MyRouterDDNS.org/ 
      - N8N_TRUST_PROXY=true
      - N8N_PUSH_BACKEND=websocket
    volumes:
      - ~/.n8n:/home/node/.n8n

  nginx:
    image: nginx:latest
    container_name: nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"

    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/ssl:/etc/nginx/ssl
      - ./certbot/www:/var/www/certbot
      - ./certbot/conf:/etc/letsencrypt
    networks:
      - n8n-network

networks:
  n8n-network:
    external: true

  • image
    finished port Forwarding and allowed ufw for 5678

Thank you. I solved this problem.

I opend

~/n8n/nginx/conf.d/default.conf

file and edit it as below.

me@ubuntuvm:~/n8n/nginx/conf.d$ cat default.conf
server {
    listen 80;
    server_name MyRouter.org;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        proxy_pass http://n8n-app:5678;
        proxy_set_header Host $host;
        
        # 
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # 
        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        proxy_connect_timeout 3600s;

        # 
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;


    }
}