When enabling trunk after restore: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'tr-peer-2-account' for key 'PRIMARY'

FPBX 13 to FPBX 13 on new server, did 13 > 14 upgrade on new server and went to re-able the trunks and got the following error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘tr-peer-2-account’ for key ‘PRIMARY’

Your database is corrupt. You can connect to the MySQL database and delete the entries and recreate it.

Have logged in with SIP provider and truncated the trunks table, but the issue persisted. Also, after nuking the trunks table, I still have trunks showing up in the chan_sip peers of Asterisk info, which is confusing.

I don’t understand your response.

Go to the server console and log in as ‘root’.

Use the command “mysql -u root asterisk” to log into mysql.

The error message above should have a table name it in (which isn’t included in the error you posted). The command is "delete from (table) where primary = ‘tr-peer-2-account’ ". This will delete the entries from the MySQL table.

Go into the Asterisk console and recreate your peer account for your trunk.

Having trouble finding which table is causing the issue. I have no trunks listed in the GUI or CLI, but under Asterisk Info > Peers, its showing trunks registered which is what I assume is causing the duplicate error?

No - the problem is that there are duplicate keys in the database. It has nothing to do with the application of the data - it’s the actual data itself. Regardless of what the FreePBX GUI or even the Asterisk server shows, the data in the database is what’s corrupt.

Once again, this isn’t a problem anywhere except the mysql database. Fix that and the warning goes away.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.