I'm on Ubuntu 20, working on a Rails 6.05 project with a Postgres DB. I've succesfully created a Heroku app using
heroku create appname and then deployed the Rails app using
git push heroku master.
The app/website is accessible and works fine on Heroku, but I'm not being able to run most console commands using the Heroku
I can deploy as described above, and also set environment variables via
heroku config:set TWILIO_KEY='123', but commands like
heroku run rails db:migrate,
heroku run rails console and most if not any other commands that I try to run via heroku run command return the following error (IP changes every time):
Running rails console on ⬢ appname... done
Error: connect ECONNREFUSED 188.8.131.52:5000
Right after I run any of these commands from my console, I can see the app logs on Heroku updating accordingly and throwing an error.
For example, for the
heroku run rails console command executed above, the app logs show:
2022-05-31T00:42:11.048694+00:00 app[api]: Starting process with command `rails console` by user [email protected]
2022-05-31T00:44:34.314621+00:00 heroku[run.6356]: Awaiting client
2022-05-31T00:44:34.307905+00:00 heroku[run.6356]: State changed from starting to up
2022-05-31T00:45:04.332589+00:00 heroku[run.6356]: Process exited with status 128
2022-05-31T00:45:04.332006+00:00 heroku[run.6356]: Error R13 (Attach error) -> Failed to attach to process
2022-05-31T00:45:04.389840+00:00 heroku[run.6356]: State changed from up to complete
The Heroku docs do not provide more information on
R13 or status 128 error codes.
The error code itself does not provide any other information regarding the connection to what is failing either.
Troubleshooting: Since it clearly doesn't seem to be a connection issue with Heroku itself but rather the project, I did a clean Ubuntu install on a laptop, disabled all firewall rules and attempted to run
heroku run rails console on both new and old projects that I used to manage just fine.
To my surprise (not) I get the same error on all the projects I try to connect to, new or old.
This got me thinking, could it be a Postgres connection problem of some sort? Is there anything that I could have missed in the setup (eg: in
database.yml) when deploying an app with a Postgres DB to production that might be causing the problem?
Any help would be appreciated.