PG::ConnectionBad (could not connect to server)

PG::ConnectionBad (could not connect to server: Connection refused
	Is the server running on host "localhost" (::1) and accepting
	TCP/IP connections on port 5432?
could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?
)

This is something that most likely resulted when a PostgreSQL server was updated but the databases weren’t updated to the current version.

Here is a simple fix that could help you.

brew postgresql-upgrade-database

 brew postgresql-upgrade-database
==> brew install postgresql@10
==> Downloading https://homebrew.bintray.com/bottles/postgresql@10-10.10_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/0b/0bfd1011bd9500221b4213c86699a13c692acdf41984e88a1b86f2397ea11f15?__gda__=exp=1568557647~hmac=02a02995ee6bde2ee4d6871f6974b36d
######################################################################## 100.0%
[......]
==> Upgraded postgresql data from 10 to 11!
==> Your postgresql 10 data remains at /usr/local/var/postgres.old
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)

Everything would hopefully be working for you too!

 Capybara Cheatsheet

Navigation

visit('/posts')
visit(post_path(post))

Clicking Links and Buttons

click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text')
click('Button Value')

Interacting with Forms

fill_in('First Name', :with => 'Mark')
fill_in('Password', :with => 'password')
fill_in('Description', :with => 'Description')
choose('radio button')
check('checkbox')
uncheck('checkbox')
attach_file('image field', '/path/to/image.png')

 Setting Ruby versions with rbenv

Use specific Ruby version with rbenv

rbenv shell _version_

$ rbenv shell 2.6.3
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
$ rbenv shell 2.5.1
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]

Set specific Ruby version globally

rbenv global _version_

$ cat ~/.rbenv/version
2.3.1
$ rbenv global 2.5.1
$ cat ~/.rbenv/version
2.5.1

Deleting global .ruby-version with rbenv

rbenv global --unset

$ rbenv global 2.5.1
$ cat ~/.rbenv/version
2.5.1
$ rbenv global --unset
$ cat ~/.rbenv/version 
cat: .ruby-version: No such file or directory

Set specific Ruby version by setting .ruby-version

rbenv local _version_

$ rbenv local 2.3.1
$ cat .ruby-version 
2.3.1
$ rbenv local 2.5.1
$ cat .ruby-version 
2.5.1

Deleting local .ruby-version with rbenv

rbenv local --unset

$ rbenv local 2.5.1
$ cat .ruby-version 
2.5.1
$ rbenv local --unset
$ cat .ruby-version 
cat: .ruby-version: No such file or directory

Reference

rbenv github project

 Managing Ruby versions using rbenv

List all Ruby versions available with rbenv

rbenv install -l

$ rbenv install -l
Available versions:
  1.8.5-p52
  1.8.5-p113
  1.8.5-p114
  1.8.5-p115
  1.8.5-p231
[...]
  truffleruby-1.0.0-rc8
  truffleruby-1.0.0-rc9

Install Ruby with rbenv

rbenv install _version_

$ rbenv install 2.5.1
ruby-build: use openssl from homebrew
Downloading ruby-2.5.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
Installing ruby-2.5.1...
ruby-build: use readline from homebrew
Installed ruby-2.5.1 to /Users/user/.rbenv/versions/2.5.1

Uninstall Ruby version with rbenv

rbenv uninstall _version_

References

rbenv project page

$ rbenv uninstall 2.4.0
rbenv: remove /Users/user/.rbenv/versions/2.4.0? [yN] y

List all installed Ruby versions with rbenv

rbenv versions

$ rbenv versions
  system
  2.0.0-p648
  2.2.3
  2.4.1
  2.5.0
* 2.5.1 (set by /Users/user/projects/project-1/.ruby-version)
  2.6.3

View current Ruby version with rbenv

rbenv version

$ rbenv version
2.5.1 (set by /Users/user/projects/project-1/.ruby-version)

Reference

rbenv github project