Go: sql: no rows in result set
QueryRow(...).Scan(...) found no row for the query.
sql: no rows in result setno rows in result set Scanpgx: no rows in result set Meaning
This is a normal "not found" signal, not a database failure. Compare with errors.Is(err, sql.ErrNoRows) and return a 404 or default. If rows were expected, check the WHERE clause, parameters and that you query the correct database/schema.
Common causes
- No matching row for the ID or filter
- Wrong parameter value or type
- Querying the wrong database/schema
- Row not yet committed (another transaction)
- Soft-deleted row filtered out
⚡ Quick fix
- Handle
sql.ErrNoRowsexplicitly - Log the SQL parameters
- Verify the data exists with a direct query
Detailed fix by platform
Go
if errors.Is(err, sql.ErrNoRows) { return nil, ErrNotFound }
How to diagnose
- Query — Parameters correct?
- DB — Right database?
- Data — Row exists?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- assignment mismatch: 1 variable but f returns 2 values Go: assignment mismatch: 1 variable but os.Open returns 2 values
- cannot assign to struct field m[k].f in map Go: cannot assign to struct field users["bob"].Age in map
- cannot find package in any of GOROOT / GOPATH Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH)
Most viewed in Go
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026