Redis : laravel connection refused [tcp://127.0.0.1:6379]
Hello,
I'm using redis for cache, I'm getting this error :
laravel connection refused [tcp://127.0.0.1:6379]
I've tried to put localhost, redis instead of 127.0.0.1 but still the same error :
Cannot assign requested address [tcp://localhost:6379]
Those appear to be different errors.... I also wonder how this is relevant to frankenphp - wouldn't it be an issue with your laravel application and redis server? Perhaps you have a password for redis? Or it uses Unix sockets?
Or might it have something to do with the phpredis extension (or whatever extension you've installed as part of frankenphp)?
Indeed, this looks more like a configuration problem on your Redis server. Could you provide more details please?
Indeed, this looks more like a configuration problem on your Redis server. Could you provide more details please?
Here's it :
REDIS_HOST=localhost // Even if I set redis
REDIS_PASSWORD=null
REDIS_PORT=6379
Config database file :
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
If you're running it inside container, it cannot reach main host by default as they are on different network subnets. "localhost" refers to frankenphp container itself, you'll either need to open network or bring in service to same network. More context would be appreciated. It looks like config issue rather than runtime error.
I'm getting the same thing, even for an external Redis cache server. Seems something is going on here.
Frankenphp used via Octane installed via Laravel Forge. If I switch to use Swoole instead works straight away. Switch back to Frankenphp and it doesn't.
I'm getting the same thing, even for an external Redis cache server. Seems something is going on here.
Frankenphp used via Octane installed via Laravel Forge. If I switch to use Swoole instead works straight away. Switch back to Frankenphp and it doesn't.
AFAIK forge allows you to have cache server type, in that case the instance is separate from your main app, in those cases you need to have them on same vpcs / subnets and let server connect, it would provision server on same network by default but depending on your deployment and network config, server might not be reachable.
Not sure how forge handles frankenphp process i.e. as standalone process in machine eith custom script or as docker process - as it's more of typical fast cgi web server config wrapper and automates most of the infrastructure config in an opinionated way with ssh interaction.
Sail on other hand uses docker as backend and this explains why you're not able to connect redis as it might be on other server and docker being in bridge mode can only see servers in it's own subnets.
Check IP ranges, make sure they share same parent subnets or your network is able to find server ( via routing table mapped - out of the scope for managed services like sail or forge ).
The same config rules would apply when you're running swoole via sail and swoole stand alone. Since they share similar architecture.
@aeq-dev can you check if you an access redis as such using nc -vz localhost 6379 from exactly the environment where your Laravel is exepcted to run?
Then check if you see any unusual hosts mapped in /etc/hosts so cat /etc/hosts and share with us.
This sounds a lot like a not related issue to me but Docker can be confusing at times.
I'm facing exactly the same issue. i run frankenphp outside as a binary, it runs simple scripts fine but as i try to correct with redis or kafka, connection is refused.