I’m building a blog site. It’s built on Rails 7 and I’ve switched from SQlite3 to PostgreSQL so that my app can run on Heroku. When I try to launch my app on Heroku I get the generic error message: "We’re sorry, but something went wrong."
After digging through the Heroku logs, this is what I get:
› Warning: heroku update available from 8.0.5 to 8.0.6.
2023-04-26T07:04:58.074841+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2023-04-26T07:05:00.000000+00:00 app[api]: Build succeeded
2023-04-26T07:05:00.172930+00:00 app[web.1]: => Booting Puma
2023-04-26T07:05:00.172963+00:00 app[web.1]: => Rails 7.0.4.3 application starting in production
2023-04-26T07:05:00.172963+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2023-04-26T07:05:01.116758+00:00 app[web.1]: Puma starting in single mode...
2023-04-26T07:05:01.116781+00:00 app[web.1]: * Puma version: 5.6.5 (ruby 3.1.2-p20) ("Birdie's Version")
2023-04-26T07:05:01.116783+00:00 app[web.1]: * Min threads: 5
2023-04-26T07:05:01.116783+00:00 app[web.1]: * Max threads: 5
2023-04-26T07:05:01.116783+00:00 app[web.1]: * Environment: production
2023-04-26T07:05:01.116783+00:00 app[web.1]: * PID: 2
2023-04-26T07:05:01.117024+00:00 app[web.1]: * Listening on http://0.0.0.0:18356
2023-04-26T07:05:01.120649+00:00 app[web.1]: Use Ctrl-C to stop
2023-04-26T07:05:01.294531+00:00 heroku[web.1]: State changed from starting to up
2023-04-26T07:05:19.244326+00:00 app[api]: Starting process with command `rails db:create` by user [email protected]
2023-04-26T07:05:22.101241+00:00 heroku[run.9744]: Awaiting client
2023-04-26T07:05:22.219821+00:00 heroku[run.9744]: State changed from starting to up
2023-04-26T07:05:22.851411+00:00 heroku[run.9744]: Starting process with command `rails db:create`
2023-04-26T07:05:28.268798+00:00 heroku[run.9744]: Process exited with status 1
2023-04-26T07:05:28.298884+00:00 heroku[run.9744]: State changed from up to complete
2023-04-26T10:28:47.730233+00:00 app[web.1]: I, [2023-04-26T10:28:47.730142 #2] INFO -- : [09ef40c9-e747-4ef7-b312-599796c6386b] Started GET "/" for 1.145.159.41 at 2023-04-26 10:28:47 +0000
2023-04-26T10:28:47.732335+00:00 app[web.1]: I, [2023-04-26T10:28:47.732265 #2] INFO -- : [09ef40c9-e747-4ef7-b312-599796c6386b] Processing by BlogPostsController#index as HTML
2023-04-26T10:28:47.734099+00:00 app[web.1]: I, [2023-04-26T10:28:47.734044 #2] INFO -- : [09ef40c9-e747-4ef7-b312-599796c6386b] Completed 500 Internal Server Error in 2ms (Allocations: 1520)
2023-04-26T10:28:47.734912+00:00 heroku[router]: at=info method=GET path="/" host=myname-blog.herokuapp.com request_id=09ef40c9-e747-4ef7-b312-599796c6386b fwd="1.145.159.41" dyno=web.1 connect=0ms service=12ms status=500 bytes=1827 protocol=https
2023-04-26T10:28:47.734961+00:00 app[web.1]: F, [2023-04-26T10:28:47.734926 #2] FATAL -- : [09ef40c9-e747-4ef7-b312-599796c6386b]
2023-04-26T10:28:47.734963+00:00 app[web.1]: [09ef40c9-e747-4ef7-b312-599796c6386b] ActiveRecord::ConnectionNotEstablished (connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
2023-04-26T10:28:47.734964+00:00 app[web.1]: Is the server running locally and accepting connections on that socket?
2023-04-26T10:28:47.734965+00:00 app[web.1]: ):
2023-04-26T10:28:47.734966+00:00 app[web.1]: [09ef40c9-e747-4ef7-b312-599796c6386b]
2023-04-26T10:28:47.734966+00:00 app[web.1]: [09ef40c9-e747-4ef7-b312-599796c6386b] app/controllers/blog_posts_controller.rb:7:in `index'
2023-04-26T10:28:48.114685+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=myname-blog.herokuapp.com request_id=17872943-0522-411a-8d92-618d73c906ad fwd="1.145.159.41" dyno=web.1 connect=0ms service=1ms status=200 bytes=15553 protocol=https
2023-04-26T10:33:23.625133+00:00 app[api]: Starting process with command `rails db:create` by user [email protected]
2023-04-26T10:33:27.181577+00:00 heroku[run.2681]: Awaiting client
2023-04-26T10:33:27.198319+00:00 heroku[run.2681]: Starting process with command `rails db:create`
2023-04-26T10:33:27.248207+00:00 heroku[run.2681]: State changed from starting to up
2023-04-26T10:33:32.007028+00:00 heroku[run.2681]: Process exited with status 1
2023-04-26T10:33:32.048189+00:00 heroku[run.2681]: State changed from up to complete
2023-04-26T10:49:17.463329+00:00 app[web.1]: I, [2023-04-26T10:49:17.463264 #2] INFO -- : [4be180a1-c5d4-4060-a0a7-5545c78fe28a] Started GET "/" for 1.145.159.41 at 2023-04-26 10:49:17 +0000
2023-04-26T10:49:17.464018+00:00 app[web.1]: I, [2023-04-26T10:49:17.463954 #2] INFO -- : [4be180a1-c5d4-4060-a0a7-5545c78fe28a] Processing by BlogPostsController#index as HTML
2023-04-26T10:49:17.464717+00:00 app[web.1]: I, [2023-04-26T10:49:17.464686 #2] INFO -- : [4be180a1-c5d4-4060-a0a7-5545c78fe28a] Completed 500 Internal Server Error in 1ms (Allocations: 865)
2023-04-26T10:49:17.465178+00:00 app[web.1]: F, [2023-04-26T10:49:17.465153 #2] FATAL -- : [4be180a1-c5d4-4060-a0a7-5545c78fe28a]
2023-04-26T10:49:17.465179+00:00 app[web.1]: [4be180a1-c5d4-4060-a0a7-5545c78fe28a] ActiveRecord::ConnectionNotEstablished (connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
2023-04-26T10:49:17.465180+00:00 app[web.1]: Is the server running locally and accepting connections on that socket?
2023-04-26T10:49:17.465181+00:00 app[web.1]: ):
2023-04-26T10:49:17.465181+00:00 app[web.1]: [4be180a1-c5d4-4060-a0a7-5545c78fe28a]
2023-04-26T10:49:17.465182+00:00 app[web.1]: [4be180a1-c5d4-4060-a0a7-5545c78fe28a] app/controllers/blog_posts_controller.rb:7:in `index'
2023-04-26T10:49:17.465388+00:00 heroku[router]: at=info method=GET path="/" host=myname-blog.herokuapp.com request_id=4be180a1-c5d4-4060-a0a7-5545c78fe28a fwd="1.145.159.41" dyno=web.1 connect=0ms service=3ms status=500 bytes=1827 protocol=https
2023-04-26T10:49:17.831119+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=myname-blog.herokuapp.com request_id=20173cc4-605b-423a-bb21-968e0b7d33ec fwd="1.145.159.41" dyno=web.1 connect=0ms service=1ms status=200 bytes=15553 protocol=https
2023-04-27T07:51:01.874384+00:00 heroku[web.1]: Cycling
2023-04-27T07:51:01.890379+00:00 heroku[web.1]: State changed from up to starting
2023-04-27T07:51:02.504938+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2023-04-27T07:51:02.629392+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2023-04-27T07:51:02.667731+00:00 app[web.1]: Exiting
2023-04-27T07:51:02.858102+00:00 heroku[web.1]: Process exited with status 143
2023-04-27T07:51:04.649358+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2023-04-27T07:51:06.214574+00:00 app[web.1]: => Booting Puma
2023-04-27T07:51:06.214598+00:00 app[web.1]: => Rails 7.0.4.3 application starting in production
2023-04-27T07:51:06.214598+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2023-04-27T07:51:07.047605+00:00 app[web.1]: Puma starting in single mode...
2023-04-27T07:51:07.047633+00:00 app[web.1]: * Puma version: 5.6.5 (ruby 3.1.2-p20) ("Birdie's Version")
2023-04-27T07:51:07.047636+00:00 app[web.1]: * Min threads: 5
2023-04-27T07:51:07.047637+00:00 app[web.1]: * Max threads: 5
2023-04-27T07:51:07.047637+00:00 app[web.1]: * Environment: production
2023-04-27T07:51:07.047637+00:00 app[web.1]: * PID: 2
2023-04-27T07:51:07.047822+00:00 app[web.1]: * Listening on http://0.0.0.0:48574
2023-04-27T07:51:07.051067+00:00 app[web.1]: Use Ctrl-C to stop
2023-04-27T07:51:07.357981+00:00 heroku[web.1]: State changed from starting to up
2023-04-27T09:10:30.000000+00:00 app[api]: Build started by user [email protected]
2023-04-27T09:10:59.411699+00:00 app[api]: Release v10 created by user [email protected]
2023-04-27T09:10:59.411699+00:00 app[api]: Deploy 903d73f0 by user [email protected]
2023-04-27T09:10:59.786911+00:00 heroku[web.1]: Restarting
2023-04-27T09:10:59.799563+00:00 heroku[web.1]: State changed from up to starting
2023-04-27T09:11:00.328611+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2023-04-27T09:11:00.368466+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2023-04-27T09:11:00.369091+00:00 app[web.1]: Exiting
2023-04-27T09:11:00.529935+00:00 heroku[web.1]: Process exited with status 143
2023-04-27T09:11:02.891039+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2023-04-27T09:11:04.415587+00:00 app[web.1]: => Booting Puma
2023-04-27T09:11:04.415609+00:00 app[web.1]: => Rails 7.0.4.3 application starting in production
2023-04-27T09:11:04.415609+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2023-04-27T09:11:05.000000+00:00 app[api]: Build succeeded
2023-04-27T09:11:05.254030+00:00 app[web.1]: Puma starting in single mode...
2023-04-27T09:11:05.254055+00:00 app[web.1]: * Puma version: 5.6.5 (ruby 3.1.2-p20) ("Birdie's Version")
2023-04-27T09:11:05.254058+00:00 app[web.1]: * Min threads: 5
2023-04-27T09:11:05.254059+00:00 app[web.1]: * Max threads: 5
2023-04-27T09:11:05.254059+00:00 app[web.1]: * Environment: production
2023-04-27T09:11:05.254059+00:00 app[web.1]: * PID: 2
2023-04-27T09:11:05.254197+00:00 app[web.1]: * Listening on http://0.0.0.0:35610
2023-04-27T09:11:05.257347+00:00 app[web.1]: Use Ctrl-C to stop
2023-04-27T09:11:05.807424+00:00 heroku[web.1]: State changed from starting to up
2023-04-27T09:11:07.323669+00:00 app[web.1]: I, [2023-04-27T09:11:07.323602 #2] INFO -- : [ceeee860-5a73-4142-a3fe-c84bf7284f48] Started GET "/" for 1.145.159.41 at 2023-04-27 09:11:07 +0000
2023-04-27T09:11:07.324817+00:00 app[web.1]: I, [2023-04-27T09:11:07.324777 #2] INFO -- : [ceeee860-5a73-4142-a3fe-c84bf7284f48] Processing by BlogPostsController#index as HTML
2023-04-27T09:11:07.326433+00:00 app[web.1]: I, [2023-04-27T09:11:07.326404 #2] INFO -- : [ceeee860-5a73-4142-a3fe-c84bf7284f48] Completed 500 Internal Server Error in 2ms (Allocations: 1813)
2023-04-27T09:11:07.326779+00:00 app[web.1]: F, [2023-04-27T09:11:07.326759 #2] FATAL -- : [ceeee860-5a73-4142-a3fe-c84bf7284f48]
2023-04-27T09:11:07.326779+00:00 app[web.1]: [ceeee860-5a73-4142-a3fe-c84bf7284f48] ActiveRecord::ConnectionNotEstablished (connection to server at "127.0.0.1", port 5432 failed: Connection refused
2023-04-27T09:11:07.326782+00:00 app[web.1]: Is the server running on that host and accepting TCP/IP connections?
2023-04-27T09:11:07.326782+00:00 app[web.1]: ):
2023-04-27T09:11:07.326783+00:00 app[web.1]: [ceeee860-5a73-4142-a3fe-c84bf7284f48]
2023-04-27T09:11:07.326783+00:00 app[web.1]: [ceeee860-5a73-4142-a3fe-c84bf7284f48] app/controllers/blog_posts_controller.rb:7:in `index'
2023-04-27T09:11:07.328061+00:00 heroku[router]: at=info method=GET path="/" host=myname-blog.herokuapp.com request_id=ceeee860-5a73-4142-a3fe-c84bf7284f48 fwd="1.145.159.41" dyno=web.1 connect=0ms service=8ms status=500 bytes=1827 protocol=https
And after running command ‘rails db:migrate’ I run into this error:
PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from /Users/my_username/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql_adapter.rb:980:in `new'
Things I’ve done so far:
Restarted the server
Uninstalled postgres then reinstalled it with brew (running PostgreSQL 14.7 (Homebrew))
Update the pg gem to pg 1.5.2
I’m not sure if there’s an error with the postgres install that’s causing this, or something else.
2
Answers
PG::Coder.new(hash) is not the problem you should looking for
Have the same, rspec pass all model tests.
Activerecord version the same activerecord-7.0.4.3
Try updating
pg
gem:bundle update pg
I was getting the same warning after upgrading to Ruby 3.2.2, and it got fixed after updating
pg
gem.