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

DanielAwujoola's avatar

Migration Error on Heroku production.ERROR: SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4"

Uploaded a web project to heroku successfully, but after running composer install and php artisan migrate i get *production.ERROR: SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4". Please help!

0 likes
13 replies
tykus's avatar

Are you using a Postgres database?

tykus's avatar
tykus
Best Answer
Level 104

Check in config/database.php that (i) the correct default connection is being used in production and (ii) that the connection charset is utf8 and not utf8mb4

3 likes
blakroku's avatar

Heroku default sets charset to utf8mb4 whiles Laravel sets it to utf8. But it wouldn't work unless the DB_CONNECTION env variable is set to DB_CONNECTION=pgsql. Because this is the only way you can reference the charset in the database configuration file for Postgres.

DanielAwujoola's avatar

@tykus thanks alot i did not change the default DB connection to pgsql so it was using the charset for default mysql connection which is utf8mb4

1 like
tykus's avatar

i did not change the default DB connection to pgsql so it was using the charset for default mysql connection which is utf8mb4

Ask me how I knew... 😆

Ramzkie's avatar

I encounterred the same error. How did you fix this? I tried to change to from utf8mb4 to utf8 but still not worked. Any solution? I tried to change my tables to utf8 but still not worked. Please help me.

captain204's avatar

Make your default database connection to look like this 'default' => ('pgsql'),

captain204's avatar

In my own case it happened when I uploaded my .env file to version control. So you need to change default database in your .env file to pgsql

Please or to participate in this conversation.