Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abenevaut's avatar

Session :: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'ip_address' at row 1

Hello,

i configured laravel to update session in database like described in documentation (https://laravel.com/docs/5.3/session#storing-data). Everything work fine for 3 websites (on localhost and web hostings), but one return me a strange behaviour (on web hosting) that i never saw before :

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'ip_address' at row 1 (SQL: insert into `sessions` (`payload`, `last_activity`, `user_id`, `ip_address`, `user_agent`, `id`) values ("PAYLOAD_BASE64_STRING", 1481189194, , USER_IP_ADDRESS unless { src 46.105.192.0/20 137.74.120.0/22 51.254.41.128/26 51.254.41.192/26 }, "USER_AGENT_SPEC", "SESSION_ID"))

As you can see, the error is related to the following content :

USER_IP_ADDRESS unless { src 46.105.192.0/20 137.74.120.0/22 51.254.41.128/26 51.254.41.192/26 }

Did you see something like this before ? What solution can i use to fix it ? Any idea ?

0 likes
6 replies
tomopongrac's avatar
Level 51

Which column type in database is column ip_address ... you need to extend widht or change type of column

tomopongrac's avatar

if you want to save four ip address i think that you need extend with (i would probably go with 255)

abenevaut's avatar

Very important, I do not interfere with the system provided by laravel. I only made the configuration and let it work alone, without any modification. It is laravel that provides me these ip addresses. Can we trust this ip address format (surely give as session information by the web hosting provider, maybe a sum of reverse proxies) ?

1 like

Please or to participate in this conversation.