# 500 internal server error email link when tracking link clicks or page visits in a campaign

**URL:** <https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081>\
**Category:** Product Support\
**Created:** [April 19, 2021, 5:10pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081 "2021-04-19T17:10:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClementBrian](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@ClementBrian](https://forum.mautic.org/u/ClementBrian)\
**Post date:** [April 19, 2021, 5:10pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/1 "2021-04-19T17:10:10Z")

</div>

**Your software**  
My Mautic version is: 3.3.2  
My PHP version is: 7.4.16  
My Database type and version is: Mysql 5.6.43

**Your problem**  
My problem is:

I have been unable to solve this issue for over four days now. I am getting 500 internal server error on my email links whenever I try to track page visits or link clicks on a double opt-in on boarding campaign. It’s good to note the error is only occurring when I am trying to track page visits or link clicks. Without tracking the error is not occurring.

What is confusing is that the error clears after refreshing the page or clicking the link again. A normal opt-in lead is unlikely to click the same link twice or refresh the page after receiving the 500 internal server error.

I have hosted mautic on shared hosting with a litespeed server. I replicated the campaign in namecheap shared hosting with a none litespeed server and the error still occurred. Upon looking at error logs I am not seeing anything.

These errors are showing in the log:

_none_

Steps I have tried to fix the problem:

1. Clearing cache.
2. Eliminating foreign characters and emoji’s on my url, page title and the landing page
3. Deactivating and uninstalling the WP Mautic wordpress plugin and activating it again.
4. Using Mautic internal landing pages
5. Masking my link with bitly
6. Increasing my PHP memory limit
7. Increasing my php post max limit

- Tracking of users with no cookie present setting is set to yes

I have tried literally everything I could think of. Kindly assist.

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [April 19, 2021, 6:45pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/2 "2021-04-19T18:45:13Z")

</div>

set permissions for your var/log folder. I have this same error periodically.

---

<div class="post-metadata">

**Author:** ![ClementBrian](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@ClementBrian](https://forum.mautic.org/u/ClementBrian)\
**Post date:** [April 19, 2021, 7:05pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/3 "2021-04-19T19:05:56Z")

</div>

Any further directions on how to do this? On my Mautic installation the folder and file permissions section shows the var/log folder is writable. Any custom permission combination you can recommend?

Current permission is set as 7 5 5

Can’t the issue be solved once and for all.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 20, 2021, 6:47am UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/4 "2021-04-20T06:47:48Z")

</div>

Hey,  
Are you using special characters in your UTM tags for that email which you are tracking?

---

<div class="post-metadata">

**Author:** ![ClementBrian](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@ClementBrian](https://forum.mautic.org/u/ClementBrian)\
**Post date:** [April 20, 2021, 9:13am UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/5 "2021-04-20T09:13:11Z")

</div>

I am actually not using any UTM tags. The goal is to track a link click or page visit for a double opt-in campaign.

---

<div class="post-metadata">

**Author:** ![ClementBrian](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@ClementBrian](https://forum.mautic.org/u/ClementBrian)\
**Post date:** [April 20, 2021, 10:43pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/6 "2021-04-20T22:43:35Z")

</div>

I have found a solution to fix the problem once and for all

1. Enable pdo\_mysql on cpanel or server

2. In app/config/local.php, at ‘db\_driver’ =\> ‘mysqli’ change it to ‘db\_driver’ =\> ‘pdo\_mysql’

3. Clear Cache by deleting the cache folder via the file manager

Did the above and links tracking visits and url clicks are opening fine without the 500 internal server error.

The error code below guided me. I had ignored it since it wasn’t triggered by my own activities. It would autogenerate itself and fill the entire error log as one error.

 ![Error log](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/8/89bf91fe76f950c815b4c69b7e14e147f6593433.png)

mautic.ERROR: CAMPAIGN: An exception occurred while executing ‘REPLACE INTO maunfbd\_campaign\_lead\_event\_failed\_log( `log_id`, `date_added`, `reason`) SELECT id, :dateAdded as date\_added, :message as reason from maunfbd\_campaign\_lead\_event\_log WHERE is\_scheduled = 1 AND lead\_id = :contactId AND campaign\_id = :campaignId AND rotation = :rotation’: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘:dateAdded as date\_added, :message as reason from maunfbd\_campaign\_lead\_event…’ at line 2

More resources on the same.

> [@An exception occurred while executing REPLACE INTO campaign\_lead\_event\_failed\_log](https://forum.mautic.org/t/an-exception-occurred-while-executing-replace-into-campaign-lead-event-failed-log/14479):
>
> Your software My Mautic version is: 2.16.2 My PHP version is: 7.3.18 Your problem My problem is: Running email fetches with command: console mautic:email:fetch in Terminal shows:: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':dateAdded as date\_added, :message as reason from campaign\_lead\_event\_log WHERE ’ at line 2 That only happened once, but similar errors started to appear in the Mautic Logs): Y…

> <https://github.com/mautic/mautic/pull/6574>
>
> \*\*Please be sure you are submitting this against the \_staging\_ branch.\*\*
> 
> \[//\]…: # ( Please answer the following questions: )
> 
> | Q | A
> | --- | ---
> | Bug fix? | Y
> | New feature? | N
> | Automated tests included? | N
> | Related user documentation PR URL | /
> | Related developer documentation PR URL | /
> | Issues addressed (#s or URLs) | \[slack message\](https://mautic.slack.com/archives/C02HU8BUT/p1536841497000100), https://github.com/mautic/mautic/issues/6509
> | BC breaks? | N
> | Deprecations? | N
> 
> \[//\]: # ( Note that all new features should have a related user and/or developer documentation PR in their respective repositories. )
> 
> \[//\]: # ( Required: )
> \#### Description:
> 
> There were this error reported several times:
> \`\`\`
> Doctrine\\DBAL\\Exception\\SyntaxErrorException: An exception occurred while executing 'REPLACE INTO mau8g\_campaign\_lead\_event\_failed\_log( \`log\_id\`, \`date\_added\`, \`reason\`) SELECT id, :dateAdded as date\_added, :message as reason from mau8g\_campaign\_lead\_event\_log WHERE is\_scheduled = 1 AND lead\_id = :contactId AND campaign\_id = :campaignId AND rotation = :rotation': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':dateAdded as date\_added, :message as reason from mau8g\_campaign\_lead\_event\_log ' at line 2 (uncaught exception) at /home/clientsiwanta/public\_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 90 while running console command \`mautic:segments:update\` \[\] \[\]
> \`\`\`
> I think it's because the \`message\` is MySql keyword and therefore I suggest to replace it with \`reason\`. My IDE is highlighting the \`message\` word as well:
> !\[screen shot 2018-09-13 at 15 23 26\](https://user-images.githubusercontent.com/1235442/45491074-136a9000-b769-11e8-91f2-008a83dadbd4.png)
> 
> 
> \[//\]: # ( As applicable: )
> \#### Steps to reproduce the bug:
> 1. Unknown.
> 
> \#### Steps to test this PR:
> 1. Code review should suffice.

---

<div class="post-metadata">

**Author:** ![Shaz3e](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/shaz3e/32/236_2.png) [@Shaz3e](https://forum.mautic.org/u/Shaz3e)\
**Post date:** [June 9, 2021, 4:29pm UTC](https://forum.mautic.org/t/500-internal-server-error-email-link-when-tracking-link-clicks-or-page-visits-in-a-campaign/19081/7 "2021-06-09T16:29:22Z")

</div>

I am having same issue tried the above method changing db\_drive to pdo\_mysql but nothing happened any other solution please
