ruby-on-railspostgresqlubuntu

Rails trying to connect to postgresql on port 5432, but it's configured for 5433


I am attempting to get rails running in an ubuntu subsystem on Windows 10.

I have installed everything needed, but rails is unable to access postgres.

In both /etc/postgresql/9.5/main/postgresql.conf and the rails config/database.yml, I have port: 5433 instead of 5432. See [1] below for why I'm using 5433.

When trying to do a database operation through rails (e.g. rails db:setup), I get this:

PG::ConnectionBad: could not connect to server: No such file or directory
  Is the server running locally and accepting
  connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
development:
  <<: *default
  database: some_database
  username: 'postgres'
  password: 'postgres'

I cannot figure out how to make rails try to start postgres on port 5433... I'm also not sure if there is a better way to solve the issue here.

Thanks for your time.

Further details:


Solution

  • For me, I believe this issue was somehow caused by something being cached by spring or some other service. After doing the following, the problem was resolved, though I'm not sure what all was required.