HTTP ERROR 500 / Duplicate entry for key 'sessions_pkey'

Describe the issue or problem
After running smoothly for a year, our OJS platform has been displaying an HTTP 500 error since the day before yesterday, which has left the site completely offline. The only error messages appearing in the Apache log are as follows:

[Tue Apr 14 12:01:16.054065 2026] [proxy_fcgi:error] [pid 3574163:tid 3574165] [remote 10.1.24.80:57348] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘fi3ksnplgob8hkefujshoq32qn’ for key ‘sessions_pkey’ in /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}(‘INSERT INTO ses…’, Array)\n#2 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘INSERT INTO ses…’, Array, Object(Closure))\n#3 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘INSERT INTO ses…’, Array, Obje…’, referer: https://eco.mdp.edu.ar/revistas/index.php/faces
[Tue Apr 14 12:01:16.079471 2026] [proxy_fcgi:error] [pid 3574163:tid 3575642] [remote 10.1.24.80:57348] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘fi3ksnplgob8hkefujshoq32qn’ for key ‘sessions_pkey’ in /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}(‘INSERT INTO ses…’, Array)\n#2 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘INSERT INTO ses…’, Array, Object(Closure))\n#3 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘INSERT INTO ses…’, Array, Obje…’, referer: https://eco.mdp.edu.ar/revistas/index.php/faces
[Tue Apr 14 12:01:17.773811 2026] [proxy_fcgi:error] [pid 3574163:tid 3574169] [remote 10.1.24.80:57348] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘fi3ksnplgob8hkefujshoq32qn’ for key ‘sessions_pkey’ in /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}(‘INSERT INTO ses…’, Array)\n#2 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘INSERT INTO ses…’, Array, Object(Closure))\n#3 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘INSERT INTO ses…’, Array, Obje…’

I have cleared the sessions table, but the error persists and the platform remains offline.

What application are you using?
For example, OJS 3.4.0.5

Any ideas? I don’t know what to do. The website is still down.

perhaps something from this one Duplicate entry '......' for for key 'sessions_pkey' aflter upgrade to 3.3.0.13 can give you some idea how to fix this .

Also this has been resolved in the 3.4.0-8 (via the PR at https://github.com/pkp/pkp-lib/pull/12081) so upgrading to that version or above should fix it .

Regards
PKP Dev Team

Thank you for your reply. Grok gave me the same answer, but since the link is broken, I can’t verify its accuracy before updating the system.

By the way, I’m using PHP 8.2.

but since the link is broken

Not sure which link

BTW, I think it’s safe to update the OJS system to the minor builds . Take a look at this upgrade demo+guide at https://www.youtube.com/watch?v=p0f29tMofik which explain the benefit to minor build updates and how to do it . Also take a look at the official upgrade doc .

Thanks a lot for the clarification and the resources! I really appreciate the guidance. I’ll get in touch with our webmaster to proceed with updating the OJS system to the latest minor build.

Hello,

We upgraded our OJS installation from version 3.4.0-5 to 3.4.0-10, but the issue previously described still persists.

Our website remains down with an HTTP 500 error. The error log continues to show the following messages:

[Tue Apr 21 10:33:36.359385 2026] [proxy_fcgi:error] [pid 29809:tid 29831] [remote 10.1.24.81:50371] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘3i4k3jrs6eujd4elj9s6ifsus9’ for key ‘sessions_pkey’ in /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}(‘INSERT INTO ses…’, Array)\n#2 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘INSERT INTO ses…’, Array, Object(Closure))\n#3 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘INSERT INTO ses…’, Array, Obje…’
[Tue Apr 21 10:33:42.929730 2026] [proxy_fcgi:error] [pid 29746:tid 29766] [remote 10.1.24.81:50372] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘3i4k3jrs6eujd4elj9s6ifsus9’ for key ‘sessions_pkey’ in /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}(‘INSERT INTO ses…’, Array)\n#2 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘INSERT INTO ses…’, Array, Object(Closure))\n#3 /var/www/FCEyS/revistas/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘INSERT INTO ses…’, Array, Obje…’

We tested the patch proposed in PR pkp/pkp-lib#9859 Enclose the insert with a try/catch, to deal with ra… by jonasraoni · Pull Request #12081 · pkp/pkp-lib · GitHub . While it resolves the HTTP 500 error, it introduces a new issue: a login loop that prevents users from accessing the platform.

After applying the patch, users are continuously redirected back to the login page, making it impossible to authenticate successfully.

At this point, the system is still unusable.

Any guidance would be greatly appreciated.

Thanks

Cristian

@cendocu sorry my last comment did not contain full possible solution so I have deleted it .

I have a theory about where it went wrong and what can fix it (unable to test it as unable to produce the problem itself in my 3.4 installation) , So need 2 file edit to test the theory as

  1. comment the line at pkp-lib/classes/session/SessionDAO.php at stable-3_4_0 · pkp/pkp-lib · GitHub. That is at the INSTALLATION_PATH/lib/pkp/classes/session/SessionDAO.php , has method insertObject which as a line as $this->updateObject($session); . comment it out as // $this->updateObject($session);
  2. At the pkp-lib/classes/session/SessionManager.php at stable-3_4_0 · pkp/pkp-lib · GitHub, e..g for method createSession(at the path INSTALLATION_PATH/lib/pkp/classes/session/SessionManager.php), modify it as follow
private function createSession(): void                                                                                                                          
{                                                                                                                                                               
    $existingSession = $this->sessionDao->getSession(session_id());
    if ($existingSession) {                                                                                                                                     
        $this->userSession = $existingSession;        
        return;                                                                                                                                                 
    }
                                                                                                                                                                
    $now = time();                                    

    $this->userSession = $this->sessionDao->newDataObject();                                                                                                    
    $this->userSession->setId(session_id());
    $this->userSession->setIpAddress($this->request->getRemoteAddr());                                                                                          
    $this->userSession->setUserAgent($this->request->getUserAgent());                                                                                           
    $this->userSession->setSecondsCreated($now);
    $this->userSession->setSecondsLastUsed($now);                                                                                                               
    $this->userSession->setDomain(ini_get('session.cookie_domain'));
    $this->userSession->setSessionData('');                                                                                                                     
                                                      
    $this->sessionDao->insertObject($this->userSession);                                                                                                        
}

see if this works .

Regrads
PKP Dev Team

Hi, I tested your proposed solution, but unfortunately it did not resolve the login loop issue. The website itself is up and running; however, we are still unable to access the dashboard. This situation is becoming quite frustrating, as we have been unable to log in for the past two weeks.

I would greatly appreciate any further guidance or support you can provide.

Thanks in advance

Hi @cendocu , this is really frustrating. can you take a look at the error log and see if there is anything new getting logged as due to login loop . In the mean time I will try to re-produce this issue in my local installation to see where the real problem is happening

Regards
PKP Dev Team

Hi, I’ve checked the error log, but nothing new is being recorded related to the login loop. It doesn’t seem like any errors are being logged at the moment.

Hi @cendocu , few more question

  1. are you guys running behind a reverse proxy and does it change the IP at every request ? if that is the case , perhaps try to set the session_check_ip to Off in the config.inc.php to see what happens
  2. are there multiple hosts set up for the config allowed_hosts in the config.inc.php ?
  3. Also is the allowed_hosts set properly ?

it feels to me that this probably not a session related issue anymore as the last code recommendation (change in 2 files) should fix it . But as I can not re-produce it in my local installation, very hard for me to confirm that real root cause .

We are not running behind a reverse proxy. The session_check_ip setting has always been set to Off. Additionally, we have only a single host defined in the allowed_hosts configuration, and it is set correctly.

///////////////

Additionally, after upgrading from version 3.4.0-5 to 3.4.0-10, the Web Feed plugin started redirecting to pages that return a 500 Internal Server Error

[Wed Apr 22 13:02:48.598598 2026] [proxy_fcgi:error] [pid 176559:tid 176565] [remote 10.1.24.80:39414] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught Error: Call to undefined method PKP\userGroup\UserGroup::withContextIds() in /var/www/FCEyS/revistas/plugins/generic/webFeed/WebFeedGatewayPlugin.php:99\nStack trace:\n#0 /var/www/FCEyS/revistas/pages/gateway/GatewayHandler.php(215): APP\plugins\generic\webFeed\WebFeedGatewayPlugin->fetch(Array, Object(APP\core\Request))\n#1 [internal function]: APP\pages\gateway\GatewayHandler->plugin(Array, Object(APP\core\Request))\n#2 /var/www/FCEyS/revistas/lib/pkp/classes/core/PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request))\n#3 /var/www/FCEyS/revistas/lib/pkp/classes/core/PKPPageRouter.php(278): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array, false)\n#4 /var/www/FCEyS/revistas/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPPageRouter->route(Object(APP\core\Request))\n#5 /var/www/FCEyS/revistas/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))\n#6…’,

We had to disable the plugin.

I think you have installed a wrong version of webfeed plugin which is not compatible with 3.4.0-x . The line undefined method PKP\userGroup\UserGroup::withContextIds points to the version compatible with OJS 3.5.0-x as this changes has been introduced in 3.5 version .

We installed this version: https://pkp.sfu.ca/ojs/download/ojs-3.4.0-10.tar.gz

It’s strange.

@cendocu few more clarifications ,

  1. is this login loop happening for every single users ?
  2. if this only happening for you or specific users, can you try to login from a different browser or in browser’s fresh incognito/private mode and see what happens ?

When testing the above No : 2, first try it without the code change the I previously asked to tests.

About the issue with webfeed plugin, it seems we bundled a wrong version of webfeed with the 3.4.0-10. Looking into it and hopefully will update the release very soon . Until then, disabling the plugin is the right choice .

@cendocu is your OJS installation path at https://eco.mdp.edu.ar/revistas/index.php/faces ?

I tried to register and login and seems can register properly (with account verify also) but trying to login with right creds does not login and redirect back to https://eco.mdp.edu.ar/revistas/index.php/faces/index . No login loop .

When checking the response headers, I noticed as following

cache-control: no-store                                                                                                                                         
  x-content-type-options: nosniff                                                                                                                                 
  cache-control: max-age=2592000                                                                                                                                  
  expires: Sun, 24 May 2026 08:44:24 GMT

There are TWO conflicting cache-control headers. OJS sets no-store (don’t cache this), but something — almost feels like Apache’s mod_expires — is adding max-age=2592000 (cache for 30 days).

The max-age=2592000 being exactly 30 days matches OJS’s default session_lifetime = 30. But this header shouldn’t be on dynamic page responses. I suspect it’s a server misconfiguration that may have existed for a while but only became visible when the session errors started (before, the cache was periodically refreshed; now, stale cached pages are stuck).

please check Apache config — look for ExpiresDefault or mod_expires as something related to ExpiresActive like

ExpiresActive On                                                                                                                                                
ExpiresDefault "access plus 30 days"

or mod_headers has something Header set Cache-Control "max-age=2592000"

Alternatively check if there is any .htaccess set and if so see adding following can help

<FilesMatch "\.php$">                                                                                                                                           
      ExpiresActive Off                                                                                                                                           
      Header set Cache-Control "no-store, no-cache, must-revalidate"                                                                                              
  </FilesMatch>

Having 2 conflicting cache-control is very odd .

Hi,

The webmaster applied your suggestion in the Apache configuration file as follows:

<Directory "/var/www/FCEyS/revistas">
    <IfModule mod_headers.c>
        Header always set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
        Header always set Pragma "no-cache"
        Header always set Expires "0"
    </IfModule>
    Options -MultiViews
</Directory>

However, the platform is still inaccessible. We also cleared the OJS cache, but the issue persists.

We are currently observing two different behaviors:

On individual journal pages, there is a login loop:
https://eco.mdp.edu.ar/revistas/index.php/faces
https://eco.mdp.edu.ar/revistas/index.php/aportes

On the main portal page, there is no loop, but it redirects to the index page:
https://eco.mdp.edu.ar/revistas

This situation has become an endless nightmare.

Any further guidance would be greatly appreciated.

Thanks a lot

Hi, at this point I am also hitting a wall . I will try to reach other team member to see if they have any idea . just few confirmation

  1. when tested with updated apache config, was the changes that mentioned at HTTP ERROR 500 / Duplicate entry for key 'sessions_pkey' - #10 by touhidur being still applied . if still applied, revert back to original state and see what happens .
  2. have you guys installed/enable any plugin right before the start of this issue ?