I have added the pg and rails_12factor gem to my gemfile and tried to push my app to heroku but the website just says application error, I was able to do this successfully a few
You must specify a specific pg version in your gemfile. If not, you will be using the latest available version (1.0.0). But this version is still not supported by Rails. Check here: https://github.com/rails/rails/issues/31673
Yous should use version 0.21
gem 'pg', '0.21'
Have you tried the command heroku logs to print output of rails server? You might find something useful to the problem you have.