If there is not present a database named postgres besides the database required by my app I get the following error every time I hit the the phoenix server.
I noticed this when making some experiments connecting my local phoenix app to a database in heroku. At first I thought that there was a problem with heroku itself.
Then I dumped the database from heroku and restored it to Digital Ocean. I got the same error. When I created another database named postgres in Digital Ocean, the error disappeared.
Finally I tested in my local machine. I had no problems until I renamed the existing database postgres to postgres2, after which I got the error again,
It is important to note that in my local machine I had only one role named hectorsq. I created a roled named postgres and the problems persists. It is required that a database named postgres exists.
In one of your config files, you will have a configuration for an ecto repo. That configuration specifies the need for a user and database, both called postgres by default. You can change these configuration options to be whatever you want them to be.
I double checked and there in no configuration that refers to a postgres database. I did a search in all my project for the word postgres and it exists only in repo.ex
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
end
However, what puzzles me is that my app shows this error every time I request a page. Perhaps it is only related to development mode, I will test in production later.
I added this option to my config pointing to the same development database and the error does not appear anymore.