Skip to main content
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

ERROR: duplicate key value violates unique constraint "tokens_pkey"


I've noticed a few of these errors in the Qlik log files and Windows Application logs. Does somebody have any idea what is causing this error and/or how to solve it?  This user does make use of the Qlik Mobile app and this error certainly has something to do with that. The app works fine for this user... but if we can get rid of the error that would be nice 😉

ERROR: duplicate key value violates unique constraint "tokens_pkey"
DETAIL: Key (token, "user")=(<some token>, <some user>) already exists.
STATEMENT: INSERT INTO qlik_mobility_registrar_service.tokens ("token", "user", "createdAt", "updatedAt") VALUES ($1, $2, to_timestamp($3), to_timestamp($4)) RETURNING *

Labels (3)
1 Reply
Partner - Creator III
Partner - Creator III

Hi Tamarah.

The error message indicates that there is a violation of a unique constraint in the Qlik Mobility Registrar Service related to the "tokens" table. It seems like the combination of "token" and "user" fields in the "tokens" table must be unique, but there is an attempt to insert a duplicate record with the same token and user values.

This issue might be occurring due to some duplicate data being sent or processed by the Qlik Mobile app. The error message points out that the combination of "token" and "user" already exists in the "tokens" table, which means a new record with the same "token" and "user" is being inserted, causing the violation of the unique constraint.

To solve this issue, you may need to investigate why duplicate records are being sent or processed. Here are some steps you can take to troubleshoot and address the problem:

  1. Check Data Integrity: Verify the data being sent from the Qlik Mobile app to the Qlik Mobility Registrar Service. Ensure that the "token" and "user" values are unique and there are no duplicates being sent.

  2. Check Code Logic: Review the code or processes responsible for sending data to the service. Make sure that there are no errors or duplicate record insertions happening unintentionally.

  3. Review Qlik Mobility App Settings: Check the Qlik Mobile app settings and configurations related to user authentication and token management. Ensure that there are no misconfigurations or errors leading to duplicate records.

  4. Check for Multiple Instances: Verify if there are multiple instances of the Qlik Mobility Registrar Service running or if there are multiple servers/processes trying to insert tokens concurrently. This could potentially cause conflicts.

  5. Monitor Logs: Continuously monitor logs for any patterns or events leading to the error. This can help identify the source of the duplicate insertions.

  6. Clear Duplicate Data: If you find any duplicate records in the "tokens" table, remove them to resolve the unique constraint violation.

It is essential to thoroughly investigate the cause of the duplicate key violation and implement the appropriate changes to prevent it from occurring in the future. If necessary, involve the Qlik support team or the team responsible for maintaining the Qlik Mobile app to get further assistance in resolving this issue.


Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.