ERROR: value too long for type character varying(255)

A string exceeds the column’s varchar length.

Seen on: PostgreSQL

Meaning

PostgreSQL rejects (doesn’t truncate) oversized values. In PostgreSQL, text has no performance penalty versus varchar.

Common causes

  • Input longer than the declared length
  • Multi-language text longer than expected
  • URLs/user agents in short columns

⚡ Quick fix

  1. Validate lengths in the app
  2. Widen the column or switch to text with a CHECK if needed

Detailed fix by platform

PostgreSQL

  1. ALTER TABLE visits ALTER COLUMN user_agent TYPE text;

How to diagnose

  1. Column — Which one (find by length)?
  2. Value — Actual length

🧠 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.