Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

satz's avatar
Level 1

Laravel Echo Server - Client can not be authenticated, got HTTP status 404

I am using docker with caddy server

Laravel Version 5.6

laravel-echo-server.json

{
  "authHost": "http://web",
  "authEndpoint": "/broadcasting/auth",
  "clients": [],
  "database": "redis",
  "databaseConfig": {
    "redis": {
      "host": "redis",
      "password":"123456",
      "options": {
        "db": 1
      }
    },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    },
    "publishPresence": true
  },
  "devMode": true,
  "host": null,
  "port": "6001",
  "protocol": "http",
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "http://localhost",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
  },
  "subscribers":{
  "http": false, "redis": true
  }

}
404 Site web is not served on this interface
echo_1      | 
echo_1      | Client can not be authenticated, got HTTP status 404
echo_1      | [6:53:36 PM] - Sending auth request to: http://web/broadcasting/auth
echo_1      | 
echo_1      | ? [6:53:36 PM] - 6k3LT_k995xxKupYAAAC could not be authenticated to private-App.User.1
echo_1      | 404 Site web is not served on this interface
echo_1      | 
echo_1      | Client can not be authenticated, got HTTP status 404

Enabled broadcast service provider in config/app.php

caddy config

http://api.app.dev, http://portal.app.dev {
    tls off
    root /var/www/public
    gzip
    fastcgi / app:9000 php
    rewrite {
        to {path} {path}/ /index.php?{query}
    }
}

docker-compose.yml

version: '3.5'
services:

  app:
    build: ./docker/php
    depends_on:
      - database
      - mongodb
      - cache
      - queue
    volumes:
      - ./:/var/www/
      - $HOME/.composer/:$HOME/.composer/
      - ./docker/php/php-custom.ini:/usr/local/etc/php/php.ini
    environment:
      - "BEANSTALKD_HOST=queue"
      - "QUEUE_DRIVER=beanstalkd"
    env_file:
      - .env

  web:
    image: abiosoft/caddy
    container_name: caddy
    volumes:
      - ./docker/caddy/prod/Caddyfile:/etc/Caddyfile
      - ./:/var/www/
      - ./storage/certs:/root/.caddy/acme/acme-v02.api.letsencrypt.org/sites
    ports:
      - 80:80
      - 443:443
    depends_on:
      - app
    environment:
      - ACME_AGREE=true


  mongodb:
    image: mongo:latest
    container_name: mongodb
    environment:
      - "MONGO_INITDB_DATABASE=${MONGO_DATABASE}"
      - "MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME}"
      - "MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}"
    volumes:
      - mongodb:/data/db
    ports:
      - 27017:27017
    command: mongod --auth --storageEngine wiredTiger
    env_file:
      - .env

  database:
    image: mariadb:latest
    volumes:
      - mysqldata:/var/lib/mysql
    environment:
      - "MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}"
      - "MYSQL_DATABASE=${DB_DATABASE}"
      - "MYSQL_USER=${DB_USERNAME}"
      - "MYSQL_PASSWORD=${DB_PASSWORD}"
    ports:
      - 3306:3306
    env_file:
      - .env

    #laravel cron
  cron:
    build: ./docker/crontab
    #container_name: cron
    volumes:
      - ./:/var/www/
    depends_on:
      - app
    environment:
      - "BEANSTALKD_HOST=queue"
      - "QUEUE_DRIVER=beanstalkd"
    env_file:
      - .env

  #laravel worker
  worker:
    build: ./docker/worker
    #container_name: worker
    volumes:
      - ./:/var/www/
    depends_on:
      - queue
      - cache
      - mongodb
      - database
    environment:
      - "BEANSTALKD_HOST=queue"
      - "QUEUE_DRIVER=beanstalkd"
    env_file:
      - .env

  cache:
    image: redis:4.0-alpine
    command: redis-server --appendonly yes --requirepass "${REDIS_PASSWORD}"
    ports:
      - 6379:6379
    env_file:
      - .env


  echo:
    build: ./docker/echo-server
    ports:
      - '6001:6001'
    depends_on:
      - app
      - web
    links:
      - web
      - cache
    volumes:
      - ./docker/echo-server/prod/laravel-echo-server.json:/app/laravel-echo-server.json:ro
      - ./storage/certs:/app/storage/certs:ro


  queue:
    image: schickling/beanstalkd


  nodejs:
    build: ./docker/nodejs
    volumes:
      - ./:/var/www/

volumes:
  mysqldata:
  mongodb:

networks:
  default:
    external:
      name: caddy-proxy

I am not sure where i did wrong!

0 likes
11 replies
JamesMowatt's avatar

I think the broadcast auth URL will need to be portal.app.dev as per your caddy config

satz's avatar
Level 1

@jamesmowatt sorry fogot to mention, that public channel is working. Only private channel am getting 404 issue.

JamesMowatt's avatar

@satz please try setting

  "authHost": "http://portal.app.dev",

Does this resolve your issue?

satz's avatar
Level 1

no it is not . I am getting ENOTFOUND

echo_1      | 
echo_1      | [3:12:20 AM] - Error authenticating -OYr7sQtmokYCU0WAAAB for private-App.User.1
echo_1      | { Error: getaddrinfo ENOTFOUND portal.glowjobs portal.glowjobs:80
echo_1      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
echo_1      |   errno: 'ENOTFOUND',
echo_1      |   code: 'ENOTFOUND',
echo_1      |   syscall: 'getaddrinfo',
echo_1      |   hostname: 'portal.app',
echo_1      |   host: 'portal.app',
echo_1      |   port: 80 }
echo_1      | Error sending authentication request.```
JamesMowatt's avatar

Have you tried running php artisan route:list to see if /broadcasting/auth is an available endpoint?

satz's avatar
Level 1

yes it available .

I even changed hostname to portal.glowjobs.lo to test.

Attached the below screenshot.

alt text

satz's avatar
Level 1

@jamesmowatt Update : This is working in Nginx , Seems to be something wrong with caddy config?

nginx config

server {
    listen 80;
    index index.php index.html;
    root /var/www/public;
    client_max_body_size 32M;
    server_name portal.glowjobs.lo;

    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
satz's avatar
Level 1

@jamesmowatt I fixed it by adding a rule 0.0.0.0:80

Below is my caddy config and am not sure whether this is the right way of doing it?

http://api.glowjobs.lo, http://portal.glowjobs.lo {
    tls off
    root /var/www/public

    gzip
    rewrite {
            to {path} {path}/ /index.php?{query}
        }
    fastcgi / app:9000 php {
         index index.php
    }

}

0.0.0.0:80 {
    tls off
    root /var/www/public
    gzip
    fastcgi / app:9000 php
     rewrite {
         to {path} {path}/ /index.php?{query}
      }
}

Thanks for helping!

JamesMowatt's avatar

That config will mean any request coming in, if you are happy with that it will continue to work.

satz's avatar
Level 1

Am not happy with that config? At least we are able to find out the root cause. What would be best way to solve it? any idea. This is okay for local development purpose.

satz's avatar
satz
OP
Best Answer
Level 1

@jamesmowatt below config is also working . It restricts with the container ip . Hope this will be a good solution


http://web:80 {
    tls off
    root /var/www/public
    gzip
    fastcgi / app:9000 php
     rewrite {
         to {path} {path}/ /index.php?{query}
      }
}

Please or to participate in this conversation.