Unable to connect to remote Redis Server

Hello everyone. I have a problem I would like to share with all.

I made a factory to connect to my local redis server. And it works. In my env file I have this config for my local redis server

'redis' => [
        'host' => '',
        'port' => 6379    ,
        'username' => '',
        'password' => '',

I created a remote server and I get this endpoint to connect with :

'session_config' => [
	'cookie_lifetime' => 60*60*1,
	'cookie_secure' => true,
	'cookie_httponly' => true,
	'phpSaveHandler' => 'redis',
	'savePath' => 'redis://<username>:<password>@redis-17266.c13.us-east-1-3.ec2.cloud.redislabs.com:17266',        
'redis' => [
	'host' => 'redis-17266.c13.us-east-1-3.ec2.cloud.redislabs.com',        
	'username' => 'default',
	'password' => 'IfKjTKsYU8FAQ1OQMSmg0cgFG0QYEanP',
	'port'   => 17266,
	//'scheme' => 'tcp',        

I have two problems :

  • When I use the remote redis, my Factory is not called but with the local, it works
  • In my logs I get this error: The server refused the connection.

Any help will be great

Any suggestions please ? :grimacing:

Refusing a connection can be due to your PHP application, attempts to establish a connection to a server, but the server rejects or denies the connection request. There can be several reasons for this error when connecting to a Redis server:

  1. Incorrect Host or Port: Double-check that the host name and port you’re using in your Redis configuration are accurate and match the actual Redis server configuration. Ensure there are no typos or mistakes in the host name or port number.
  2. Firewall or Network Issues: A firewall, network configuration, or security group rules might be preventing the connection between your PHP application and the Redis server. Ensure that the necessary ports are open and accessible between the two systems.
  3. Redis Server Not Running: Make sure that the Redis server is up and running on the specified host and port. If the server is not running, connection attempts will be refused.
  4. Authentication Issues: If you’re using authentication (a password) to connect to the Redis server, verify that the username and password in your configuration are correct. A mismatched or incorrect password will result in a connection refusal.
  5. Redis Configuration: Check the Redis server’s configuration to ensure that it is configured to accept incoming connections, especially if it is a remote server or hosted on a cloud platform.
  6. Resource Limitation: If the Redis server or your hosting environment has resource limitations (such as max connections), attempting to connect when the limit is reached can result in connection refusals.
  7. Redis Configuration Binding: The Redis server might be configured to only bind to a specific IP address or network interface. Make sure the Redis server configuration allows connections from the source IP of your PHP application.
1 Like