tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.65k stars 512 forks source link

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 #369

Open fauzanmh opened 5 years ago

fauzanmh commented 5 years ago

i try run laravel-echo-server start but i have error like this

L A R A V E L E C H O S E R V E R

version 1.5.0

⚠ Starting server in DEV mode...

✔ Running at localhost on port 6001 ✔ Channels are ready. ✔ Listening for http events... [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)

solution for me?

sorryForMyEnglish

jeeknowme commented 5 years ago

I also got this error

mehdisadeghidev commented 5 years ago

make sure redis server is running

j0hnys commented 5 years ago

If you don't want to use redis set "redis": false in laravel-echo-server.json. The init wizard does not does this automatically if you choose sqlite for persistant storage

hassanuos commented 5 years ago

I have the same issue. Is there any solution. Capture

waqas83 commented 5 years ago

Seems like Redis is not installed or the Redis server is not running. Install a copy from https://redis.io/ And then run the service with "redis-server". After that you can smoothly run "laravel-echo-server start"

hassanuos commented 5 years ago

@waqas83 issue resolved actually the redis was not properly installed on windows 10

williamtrindade commented 5 years ago

run the command
sudo apt install redis-server

chithresuganesan commented 5 years ago

Great...

neologicx-resources-india commented 5 years ago

you just have to download the Redis server from the website below and execute redis-server.exe to start redis server.

https://riptutorial.com/redis/example/29962/installing-and-running-redis-server-on-windows

liyansasongko commented 5 years ago

install redis-server

jhoanborges commented 5 years ago

run the command sudo apt install redis-server

This is the final solution. thanks

theavuthnhel commented 4 years ago

run the command sudo apt install redis-server

It was solved. thanks

mhemrg commented 4 years ago

As @j0hnys said, you need to add the following config to your laravel-echo-server.json file:

"subscribers": {
    "http": true,
    "redis": false
}
theavuthnhel commented 4 years ago

This document is for those who use laravel echo server & nginx & socket.io & redis-server with separated server between client project and redis-server.

1) Edit /etc/redis/redis.conf

bind 127.0.0.1
supervised no

To

bind 0.0.0.0
supervised systemd

2) Update /etc/systemd/system/redis.service under [Service]

Type=notify
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf  --supervised systemd

3) Nginx /etc/nginx/sites-enabled/reverse-proxy.conf

server {
  listen        443 ssl;
  listen        [::]:443 ssl;
  server_name   mysitecom;

  error_log     /var/log/nginx/proxy-error.log error;

  # Start the SSL configurations
  ssl                         on;
  ssl_certificate             /etc/nginx/certs/mysitecom.pem;
  ssl_certificate_key         /etc/nginx/certs/mysitecom.key;
  ssl_session_timeout         3m;
  ssl_session_cache           shared:SSL:50m;
  ssl_protocols               TLSv1.1 TLSv1.2;

  # Diffie Hellmann performance improvements
  ssl_ecdh_curve              secp384r1;

  location /socket.io {
    proxy_pass                          http://mysitecom:2096;
    proxy_http_version 1.1;
    proxy_set_header Upgrade            $http_upgrade;
    proxy_set_header Connection         "upgrade";
    proxy_set_header Host               $host;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_buffers 16 4k;
    proxy_buffer_size 2k;

    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto  https;
    proxy_set_header X-VerifiedViaNginx yes;
    proxy_read_timeout                  2h;
    proxy_connect_timeout               2h;
    proxy_redirect                      off;
  }
}

4) laravel-echo-server.json

{
    "authHost": "https://mysitecom",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "e45c056ec8ca8bd7",
            "key": "88d316b5cccafbc5e905aa9ee13e63f7"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "host": "0.0.0.0",
            "port": "6379"
        },
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "2096",
    "protocol": "https",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "/etc/nginx/certs/mysitecom.pem",
    "sslKeyPath": "/etc/nginx/certs/mysitecom.key",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": true,
        "allowOrigin": "*",
        "allowMethods": "GET, POST",
        "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
    }
}

Note: for someone who connects DNS with cloudflare please change default socket.io port 6001 to the following here.

Kristoffer95 commented 4 years ago

Do this sudo service redis-server start

weldem commented 3 years ago

Or you can use docker:

docker pull redis
docker run -p 6379:6379 --name redis -d redis
cope commented 3 years ago

What about if redis dies? How can we handle that case?

There should be a fallback possibility for that case.

audelqua commented 1 year ago

I was running docker, So terminating and starting docker fixed my issue

MechaMahmud71 commented 1 year ago
const redis = new Redis({
    host: "localhost",
    port: 6900
})

this code runs on my local mechine with redis docker image. But when I dockerize my nodejs code and try to run the code it shows this error [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6900 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)

Redis container is running fine in Port 6900