# Getting timeouts on second request using express-session and serverless-http

**URL:** <https://forum.serverless.com/t/getting-timeouts-on-second-request-using-express-session-and-serverless-http/11156>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [April 16, 2020, 1:52pm UTC](https://forum.serverless.com/t/getting-timeouts-on-second-request-using-express-session-and-serverless-http/11156 "2020-04-16T13:52:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrlian](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@mrlian](https://forum.serverless.com/u/mrlian)\
**Post date:** [April 16, 2020, 1:52pm UTC](https://forum.serverless.com/t/getting-timeouts-on-second-request-using-express-session-and-serverless-http/11156/1 "2020-04-16T13:52:11Z")

</div>

Hi there,

We are moving our existing ExpressJS REST API over to Serverless using serverless-http/AWS/Lambda and have a problem with express-session. We’ve done what we think is correct:

- Of course using data store, not MemoryStore.
- First we tried to keep existing PostgreSQL data store for session.
- When that did not work we assumed it was because of database connection/pool.
- Now we changed to using DynamoDB as data store for express-session.
- But same problem persists.

Details about the problem:

- Hitting the API endpoint first time is fine, response is coming correctly back.
- But the second time and onwards 502 Bad Gateway “internal server error” returnended.
- Waiting long enough we get a 200 again, problem when Lambda function is cold.

If I comment out the express-session code it works as it should. Has anyone succeded in using express-session with Serverless/Lambda?

Thanks,  
Marius
