question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: connect ECONNREFUSED when running migration (pg driver)

See original GitHub issue

I am using postgresql and I get this error when I try to execute a migration:

[ERROR] Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)

In my database.json I have this configuration:

{
  "dev": {
    "driver": "pg"
  },
  "pg": {
    "driver": "pg",
    "user": "test",
    "password": "test",
    "host": "postgres://localhost:5433",
    "database": "testdb",
    "schema": "public"
  }
}

I can execute sql code inside my app but I can’t using migrations

Probably the problem comes because the port I am using is different from which uses the package? I think it is a bit strange because I tried with Docker where I have the port 5432 and I get the same errors.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
abaracedocommented, Jul 24, 2017

@wzrdtales I have solved the problem. As you said it was about the IP, as I am using docker-compose I did not specify the environment on my web service and I was trying to connect two containers with localhost.

2reactions
felipel1292commented, May 27, 2017

Try this.

“pg”: { “driver”: “pg”, “user”: “test”, “host”: “localhost”, “port”: 5433, “database”: “testdb”, “schema”: “public” }

Read more comments on GitHub >

github_iconTop Results From Across the Web

connect ECONNREFUSED 127.0.0.1:5432 docker migrate ...
A solution for this problem is using a script that only launches the server a few seconds after the db has started. In...
Read more >
Error: connect ECONNREFUSED 127.0.0.1:5432
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the ...
Read more >
error: connect econnrefused 127.0.0.1:5432 at ... - You.com
I set up the pg Pool correctly, and it works just fine if I want to connect it to my AWS postgres server...
Read more >
FATAL: Ident authentication failed for user - Unable to connect ...
Password authentication failed with PostgreSQL 9 · Bitbucket fails to connect to PostgreSQL Server with a "Connection refused" error · Database migration to ......
Read more >
Connect from Cloud Run | Cloud SQL for PostgreSQL
Note: Some drivers require the `unix_sock` query parameter to use a different key. # For example, 'psycopg2' uses the path set to `host`...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found