Problem with PostgreSQL

Hi
I’ve tried to start my new project from this tutorial. Everything went fine until I’ve tried to execute command

> mix ecto.create

Error trace is:

PS C:\elixir_project\intro\tasklist2> mix ecto.create
Compiling 13 files (.ex)
Generated tasklist2 app

21:04:02.764 [error] GenServer #PID<0.352.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
    (db_connection 2.2.1) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.8) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

Next time I got this error:

PS C:\elixir_project\tasklist> mix ecto.create
Compiling 13 files (.ex)
Generated tasklist app
** (Mix) The database for Tasklist.Repo couldn't be created: connection not available and request was dropped from queue after 2000ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:

  1. By tracking down slow queries and making sure they are running fast enough
  2. Increasing the pool_size (albeit it increases resource consumption)
  3. Allow requests to wait longer by increasing :queue_target and :queue_interval

See DBConnection.start_link/2 for more information

Configuration of dev.exs is default:

# Configure your database
config :tasklist, Tasklist.Repo,
  username: "postgres",
  password: "postgres",
  database: "tasklist_dev",
  hostname: "localhost",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10

What may cause this problem?

Database is initialy configured in the dev.exs

The error message is indicating that it can’t connect to postgres on port 5432. Are you sure postgres is running? Can you connect to it via psql?

1 Like

I’m able to connect providing password mentioned in configuration

Can you show the psql command that successfully connects?

Console output is like

Server [localhost]:
Database [postgres]:
Port [5433]:
Username [postgres]:
Password for user postgres:
psql (12.2)
WARNING: Console code page (852) differs from Windows code page (1250)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=#



This is different from the port you have specified in your mix config, which defaults to 5432. Add port: 5433 to your mix config.

3 Likes

Thanks! It helped :smiley:

PS C:\elixir_project\tasklist> mix ecto.create
Compiling 13 files (.ex)
Generated tasklist app
The database for Tasklist.Repo has been created
PS C:\elixir_project\tasklist>
3 Likes

Next issue appeared

[warn] Phoenix is unable to create symlinks. Phoenix' code reloader will run considerably faster if symlinks are allowed. On Windows, the lack of symlinks may even cause empty assets to be served. Luckily, you can address this issue by starting your Windows terminal at least once with "Run as Administrator" and then running your Phoenix application.
[info] Running TasklistWeb.Endpoint with cowboy 2.7.0 at 0.0.0.0:4000 (http)
[error] Could not start watcher because "node" is not available. Your Phoenix application is still running, however assets won't be compiled. You may fix this by installing "node" and then running "cd assets && npm install".
[info] Access TasklistWeb.Endpoint at http://localhost:4000
[info] GET /
[debug] Processing with TasklistWeb.PageController.index/2

after I executed demanded command the result was

 cd tasklist
PS C:\elixir_project\tasklist> cd assets
PS C:\elixir_project\tasklist\assets> npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN assets No description
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: abbrev@1.1.1 (node_modules\fsevents\node_modules\abbrev):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\abbrev' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.abbrev.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ansi-regex@2.1.1 (node_modules\fsevents\node_modules\ansi-regex):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\ansi-regex' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.ansi-regex.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: aproba@1.2.0 (node_modules\fsevents\node_modules\aproba):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\aproba' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.aproba.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: balanced-match@1.0.0 (node_modules\fsevents\node_modules\balanced-match):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\balanced-match' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.balanced-match.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: chownr@1.1.3 (node_modules\fsevents\node_modules\chownr):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\chownr' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.chownr.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: code-point-at@1.1.0 (node_modules\fsevents\node_modules\code-point-at):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\code-point-at' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.code-point-at.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: concat-map@0.0.1 (node_modules\fsevents\node_modules\concat-map):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\concat-map' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.concat-map.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: console-control-strings@1.1.0 (node_modules\fsevents\node_modules\console-control-strings):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\console-control-strings' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.console-control-strings.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: core-util-is@1.0.2 (node_modules\fsevents\node_modules\core-util-is):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\core-util-is' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.core-util-is.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: deep-extend@0.6.0 (node_modules\fsevents\node_modules\deep-extend):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\deep-extend' -> 'C:\elixir_project\tasklist\assets\node_modules\fsevents\node_modules\.deep-extend.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: delegates@1.0.0 (node_modules\fsevents\node_modules\delegates):

Now we’re in NodeJS territory which I tend to know little about in general, in particular on windows! Hopefully someone else can hop in.

You can ignore the npm warnings, they are much more noisy on windows. ^.^;

Does it work now though?

2 Likes

As @OvermindDL1 said you don’t need to worry about the NPM stuff. However if you feel the need to know what it is about… “Fsevents” is a Mac specific file system integration used for things like webpack to know when to recompile the JS as it improves performance over alternatives on the platform. It is basically just telling you it is skipping that and all of its related dependencies because it has a OS check and your not using the matching OS.

3 Likes