Socket error on read socket
-
I am using the latest version of Redis Object Cache and WordPress.
Recently from time to time, I will encounter the following error when trying to publish or update posts:
Error establishing a Redis connection
socket error on read socketWordPress is unable to establish a connection to Redis. This means that the connection information in your
wp-config.phpfile are incorrect, or that the Redis server is not reachable.But this error is temporary. If I press back in the browser, the post list or the post will be able to show again. Then after some time, it will appear again.
Why?
-
Please post your diagnostics and read the FAQ. You might need to increase timeouts.
How to get diagnostics?
Please post your diagnostics and read the FAQ. You might need to increase timeouts.
I try to increase the timeout and read timeout from default 1 to 5, but still get this error.
The only solution is to flush the cache.
How large is your redis dataset?
redis-cli dbsizeAfter flushing, it is 42623 now.
How large is your redis dataset?
redis-cli dbsizeWhat does
redis-cli -s slowlog get 10show?It shows “Could not connect to Redis at slowlog: No such file or directory”
What does
redis-cli -s slowlog get 10show?Try giving
redis-cliyour host and port so it connects. We’d need to look at yourSLOWLOGto see whats causing these timeouts.OK. Below are the slow logs:
1) 1) (integer) 2714
2) (integer) 1767669302
3) (integer) 38971
4) 1) "ZREMRANGEBYSCORE"
2) "site1-sitewp:redis-cache:metrics"
3) "0"
4) "1767665702"
2) 1) (integer) 2713
2) (integer) 1767668401
3) (integer) 15643
4) 1) "ZREMRANGEBYSCORE"
2) "site2-sitewp:redis-cache:metrics"
3) "0"
4) "1767664801"
3) 1) (integer) 2712
2) (integer) 1767665706
3) (integer) 29917
4) 1) "ZREMRANGEBYSCORE"
2) "site1-sitewp:redis-cache:metrics"
3) "0"
4) "1767662106"
4) 1) (integer) 2711
2) (integer) 1767664802
3) (integer) 14958
4) 1) "ZREMRANGEBYSCORE"
2) "site2-sitewp:redis-cache:metrics"
3) "0"
4) "1767661202"
5) 1) (integer) 2710
2) (integer) 1767662104
3) (integer) 32010
4) 1) "ZREMRANGEBYSCORE"
2) "site1-sitewp:redis-cache:metrics"
3) "0"
4) "1767658504"
6) 1) (integer) 2709
2) (integer) 1767661202
3) (integer) 16217
4) 1) "ZREMRANGEBYSCORE"
2) "site2-sitewp:redis-cache:metrics"
3) "0"
4) "1767657602"
7) 1) (integer) 2708
2) (integer) 1767658508
3) (integer) 48554
4) 1) "ZREMRANGEBYSCORE"
2) "site1-sitewp:redis-cache:metrics"
3) "0"
4) "1767654908"
8) 1) (integer) 2707
2) (integer) 1767657602
3) (integer) 14377
4) 1) "ZREMRANGEBYSCORE"
2) "site2-sitewp:redis-cache:metrics"
3) "0"
4) "1767654002"
9) 1) (integer) 2706
2) (integer) 1767654909
3) (integer) 26049
4) 1) "ZREMRANGEBYSCORE"
2) "site1-sitewp:redis-cache:metrics"
3) "0"
4) "1767651309"
10) 1) (integer) 2705
2) (integer) 1767654002
3) (integer) 15870
4) 1) "ZREMRANGEBYSCORE"
2) "site2-sitewp:redis-cache:metrics"
3) "0"
4) "1767650402"That’s odd, no slow Lua scripts. Please post your diagnostics from Settings > Redis.
The diagnostics log is:
Status: Connected
Client: PhpRedis (v6.0.2)
Drop-in: Valid
Disabled: No
Ping: 1
Errors: []
PhpRedis: 6.0.2
Relay: Not loaded
Predis: 2.4.0
Credis: Not loaded
PHP Version: 8.2.30
Plugin Version: 2.7.0
Redis Version: 3.2.12
Multisite: No
Metrics: Enabled
Metrics recorded: 15683
Filesystem: Writable
Global Prefix: "wp_"
Blog Prefix: "wp_"
Timeout: 1
Read Timeout: 1
Retry Interval:
WP_REDIS_DATABASE: 0
WP_REDIS_PREFIX: "site1"
WP_REDIS_PLUGIN_PATH: "/home/username/public_html/wp-content/plugins/redis-cache"
Global Groups: [
"blog-details",
"blog-id-cache",
"blog-lookup",
"global-posts",
"networks",
"rss",
"sites",
"site-details",
"site-lookup",
"site-options",
"site-transient",
"users",
"useremail",
"userlogins",
"usermeta",
"user_meta",
"userslugs",
"redis-cache",
"blog_meta",
"image_editor",
"network-queries",
"site-queries",
"theme_files",
"translation_files",
"user-queries"
]
Ignored Groups: [
"counts",
"plugins",
"theme_json",
"themes",
"WPForms_Entry_Handler"
]
Unflushable Groups: []
Groups Types: {
"blog-details": "global",
"blog-id-cache": "global",
"blog-lookup": "global",
"global-posts": "global",
"networks": "global",
"rss": "global",
"sites": "global",
"site-details": "global",
"site-lookup": "global",
"site-options": "global",
"site-transient": "global",
"users": "global",
"useremail": "global",
"userlogins": "global",
"usermeta": "global",
"user_meta": "global",
"userslugs": "global",
"redis-cache": "global",
"blog_meta": "global",
"image_editor": "global",
"network-queries": "global",
"site-queries": "global",
"theme_files": "global",
"translation_files": "global",
"user-queries": "global",
"counts": "ignored",
"plugins": "ignored",
"theme_json": "ignored",
"themes": "ignored",
"WPForms_Entry_Handler": "ignored"
}
Drop-ins: [
"advanced-cache.php v by ",
"maintenance.php v by ",
"Redis Object Cache Drop-In v2.7.0 by Till Krüss"
]Thank you.
Try increasing the read timeout for 3 or 5 seconds, that might resolve it.
In the past, I have already tried to increase both the timeout and read timeout to 5 seconds. But that does not work. The only solution is flush the cache. And when I flush the cache for the first time, I will also get an error that seems your plugin cannot connect to the Redis server. But soon it becames OK.
You must be logged in to reply to this topic.