Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems connecting to PostgreSQL, under OSX 10.6.8 #6

Closed
preslavrachev opened this issue Dec 9, 2012 · 5 comments
Closed

Problems connecting to PostgreSQL, under OSX 10.6.8 #6

preslavrachev opened this issue Dec 9, 2012 · 5 comments

Comments

@preslavrachev
Copy link

I am trying to make a small nodejs app run under osx (10.6.8), and connect to my localhost Postgres database. I am using node-orm (https://github.com/dresende/node-orm2) as well as the Postgres bindings (https://github.com/brianc/node-postgres).

For some reason, when I use orm.connect and give it the connection url as a string, it fails with:

Error: getaddrinfo ENOENT at errnoException (dns.js:31:11) at Object.onanswer [as oncomplete] (dns.js:123:16)

If I change localhost with 127.0.0.1. it also dies with a timeout exception.

Using the vanilla postgress bindings to connect to the DB, using the same connection string is successful, and I even managed to get a few test queries running, got results, etc.

I tried to set up the DB client manually using the vanilla postgress api, an pass it on to orm using orm.use. This manages to connect successfully to the DB, but every time I try to execute a query, nothing happens. It does not generate an error, but sinply gets stuck in the QueryQueue and does not call the success callback. I checked the DB logs, and it seems that it has not detected the query either.

What do I do? I am a bit confused

@dresende
Copy link
Owner

dresende commented Dec 9, 2012

I'm confused too. Can you post an example?

@dresende
Copy link
Owner

Please give me some feedback, some versions of postgres, node, ...

@preslavrachev
Copy link
Author

Found the issue and partially solved it.

The initial connection string:
postgresql://user:pass@localhost:5432/db_name

When I used it in orm.connect, I put a breakpoint at the point where ORM converts the string to an object of options. The following opts object was generated:

{

auth: "user:pass",
database: "db_name",
host: "localhost:5432",
hostname: "localhost",
href: "postgresql://user:pass@localhost:5432/db_name",
password: "pass",
path: "/db_name",
pathname: "/db_name",
port: "5432",
protocol: "postgresql:",
query: {},
search: "",
slashes: true,
user: "user"

}

Instead of a connection url string, I created an options object with this data, and used it in orm.connect. It blew up with the same error.
Then, I changed host: "localhost:5432" with host: "localhost:", and it started working!

Postgres ver: 9.1
Node ver: 0.8.5
npm ver: 1.1.46

@dresende
Copy link
Owner

So the problem is the port definition? Hmmm... I have to check that..

@dresende
Copy link
Owner

Could you try the latest commit? I change the way drivers use the config. More specifically, mysql and postgres will try to use the url string before trying the parsed object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants