# Intermittent API Errors (500 Internal Server Error)

**URL:** https://forum.mautic.org/t/intermittent-api-errors-500-internal-server-error/26236
**Category:** Product Support
**Created:** [November 29, 2022, 3:24pm UTC](https://forum.mautic.org/t/intermittent-api-errors-500-internal-server-error/26236 "2022-11-29T15:24:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pwnapple](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pwnapple/32/8041_2.png) [@pwnapple](https://forum.mautic.org/u/pwnapple)
#### Post date: [November 29, 2022, 3:24pm UTC](https://forum.mautic.org/t/intermittent-api-errors-500-internal-server-error/26236/1 "2022-11-29T15:24:48Z")

</div>

My Mautic version is: 4.4.2  
My PHP version is: 8.0.24  
My Database type and version is: MySql 8.0.28

My problem is:  
I have successfully installed Mautic self-hosted (2 core, 4GB mem) and am using it for multiple campaigns/emails/contact mgmt/etc.

I am using the API to add contacts to segments/trigger campaigns and every now and then I get 500 Internal Server Errors intermittently.  
ex. `POST https://mymautic.com/api/segments/<segmentId>/contact/<contactId>/add`

I don’t see anything crazy in the CPU/Memory logs, in fact, the instance is underutilized!

These errors are showing in the log:

Looking at the log in the System Info page, I see stuff like the following happening every hour or so:

> **[\[2022-11-29 00:00:16\] mautic.CRITICAL: Uncaught PHP Exception...](https://pastebin.com/vMLaFgNk)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

I understand there’s a FK violation going on but I don’t understand why it’s happening. Is it b/c for ex. there’s already a user in the segment/campaign or…?

Steps I have tried to fix the problem:

I’ve added retries client side…but that doesn’t solve the root cause of course 😕
