Redis Error Guide: 'ERR value is not a valid float' — Fix INCRBYFLOAT and Sorted-Set Scores
Fix ERR value is not a valid float in Redis: diagnose non-numeric stored values, bad INCRBYFLOAT input, locale decimal commas, and NaN on ZADD scores.
- #redis
- #database
- #troubleshooting
- #errors
Stuck on this Redis error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Overview
Redis returns value is not a valid float when a floating-point command is asked to parse something that is not a number it accepts. It shows up on INCRBYFLOAT, HINCRBYFLOAT, and ZADD/ZINCRBY scores — either because the stored value cannot be read as a float, or because the increment/score you supplied is not a valid float.
The literal error clients receive:
(error) ERR value is not a valid float
This is the float cousin of value is not an integer or out of range. Common culprits: a value written with a locale comma (3,14), leading/trailing whitespace, an empty string, or NaN/Inf where finite numbers are required.
Symptoms
INCRBYFLOAT/HINCRBYFLOATfails while a plainGETreturns the key fine.ZADD key <score> memberfails with a score that “looks” numeric to a human.- Started after data was imported from a locale that uses
,as the decimal separator.
redis-cli SET price "12,50"
redis-cli INCRBYFLOAT price 1.0
(error) ERR value is not a valid float
Common Root Causes
1. Stored value is not float-parseable
The existing key holds text, a comma-decimal, or trailing characters ("12.50 USD").
redis-cli GET price
"12,50"
2. The increment/score argument is malformed
redis-cli INCRBYFLOAT counter "1,5" # comma, not dot
redis-cli ZADD leaderboard "" alice # empty score
3. NaN or Infinity supplied
ZADD/ZINCRBY accept +inf/-inf as scores but reject nan; an INCRBYFLOAT that would produce nan/inf is rejected too.
redis-cli ZINCRBY leaderboard nan alice
(error) ERR value is not a valid float
4. Hidden whitespace or Unicode digits
A trailing \r, a non-breaking space, or full-width digits from a bad import will not parse.
How to diagnose
Step 1: Read the raw stored value
redis-cli GET price
redis-cli TYPE price
If it prints "12,50", "12.50 USD", or an empty string, that is the problem.
Step 2: Reveal hidden characters
redis-cli --no-raw GET price
"12.50\r"
--no-raw shows escape sequences like \r or embedded quotes that a normal print hides.
Step 3: Test the argument in isolation
redis-cli SET tmpfloat 0
redis-cli INCRBYFLOAT tmpfloat 1.5 # confirm a clean float works
redis-cli DEL tmpfloat
Step 4: For sorted sets, check the score you are sending
redis-cli ZADD testset 3.14 member # valid
redis-cli ZADD testset 3,14 member # invalid -> the error
Fixes
Normalize the stored value to a dot-decimal number
redis-cli SET price "12.50"
redis-cli INCRBYFLOAT price 1.0
"13.5"
Send increments/scores with a dot decimal, no thousands separators
redis-cli INCRBYFLOAT counter 1.5
redis-cli ZADD leaderboard 100.25 alice
Sanitize input at the application boundary
Trim whitespace and convert locale commas before writing:
raw = user_input.strip().replace(",", ".")
r.set("price", float(raw)) # store a clean numeric string
Use +inf / -inf intentionally, never nan
redis-cli ZADD leaderboard +inf vip # allowed
What to watch out for
- Redis stores numbers as strings; a value that “looks” numeric can still carry invisible bytes. Always check with
--no-rawwhen parsing fails. INCRBYFLOATresults are formatted without trailing zeros (13.5, not13.50) — don’t rely on fixed decimal places.- Sorted-set scores are IEEE 754 doubles; extreme magnitudes lose precision even when they parse.
- Bulk imports from spreadsheets are the top source of comma-decimal values; validate during ingestion, not at read time.
Related
- Redis Error: ‘value is not an integer or out of range’
- Redis Error: ‘increment or decrement would overflow’
- Redis Error: ‘WRONGTYPE Operation against a key holding the wrong kind of value’
Paste the failing command into the free incident assistant, and browse more Redis guides.
Fixed it? Get 500 Redis & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Did this fix your issue?
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.