Hey Anuj, I have been experiencing similar issues but with these two codes.
Have you got the solution yet? If yes then share please. It will be so helpful in completing my project.
In my case application is not able to access the database and i found there was issue with pg_hba.conf file. i have made the changes and it worked for me. Application was able to connect to database.