Predis\Connection\ConnectionException: Cannot assign requested address [tcp://127.0.0.1:6379] Recently, one of our servers started reporting this error intermittently:
Predis\Connection\ConnectionException: Cannot assign requested address [tcp://127.0.0.1:6379]
In:
vendor/predis/predis/src/Connection/AbstractConnection.php:155 - Predis\Connection\AbstractConnection::onConnectionError
Triggered by: artisan queue:work redis --once
Ours is a standard Laravel 5.7 installation on an Ubuntu vm provisioned with Forge. There has been no change to any settings but this error suddenly appeared. Any ideas as to what might be going on?
It sounds like you have something already bound to port 6379. You can check running netstat -vatnl | grep 6379 from the command line and checking for anything with the same port. You'll probably see some TIME_WAIT or LISTENING connections.
@d9705996 Thanks. This is the result of the command:
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6379 127.0.0.1:58244 ESTABLISHED
tcp 0 0 127.0.0.1:52098 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:51171 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:6379 127.0.0.1:33028 ESTABLISHED
tcp 0 0 127.0.0.1:49731 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:41169 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:60007 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:51065 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:52277 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:47116 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:56150 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:36441 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:35296 ESTABLISHED
tcp 0 0 127.0.0.1:47272 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:36221 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:41169 ESTABLISHED
tcp 0 0 127.0.0.1:49921 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:6379 127.0.0.1:60007 ESTABLISHED
tcp 0 0 127.0.0.1:45921 127.0.0.1:6379 TIME_WAIT
tcp 0 14 127.0.0.1:6379 127.0.0.1:53708 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:42849 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:36441 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:38599 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:53578 ESTABLISHED
tcp 0 0 127.0.0.1:6379 127.0.0.1:56150 ESTABLISHED
tcp 0 0 127.0.0.1:38599 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:48411 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:6379 127.0.0.1:36221 ESTABLISHED
tcp 0 0 127.0.0.1:42849 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:48276 127.0.0.1:6379 TIME_WAIT
tcp 0 0 127.0.0.1:53578 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:35296 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:58244 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:53708 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:33028 127.0.0.1:6379 ESTABLISHED
tcp 0 0 127.0.0.1:46072 127.0.0.1:6379 TIME_WAIT
I'm not very familiar with what's going on. Should there be this many? Can I zero in on any problem that might be happening?
Without seeing you code it is hard to tell but I think you might be trying to create new Predis connections, rather than re-using an existing connection.
Could you share your code that is interacting with the redis queue?
Please sign in or create an account to participate in this conversation.