Is that possible to close the database connection after running each database query in Laravel 5.1. I have already built an application by using the Laravel 5.1 and PostgreSQL, and in my server there are limited number of connections has been provided to connect with the database, that's why sometimes I am getting the error "To Many Connections". So please tell me how I can resolve this problem.
I am not sure if Laravel automatically closes the db connection after each db request.
Thanks in advance...
You could use DB::disconnect('foo');
But keep in mind Laravel closes connection to DB automatically at the end of the script.
So your problem is somewhere else.
Workaounrd here would be unlimit connection from localhost
or for particular user
. Because each visitor of your website opens a new connection to DB
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With