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

Able to connect to the postgres unix socket #3013

Closed
rgl opened this issue Apr 24, 2016 · 10 comments
Closed

Able to connect to the postgres unix socket #3013

rgl opened this issue Apr 24, 2016 · 10 comments
Assignees
Labels
🔨 enhancement Make it better, faster status: needs feedback Tell me more about it
Milestone

Comments

@rgl
Copy link

rgl commented Apr 24, 2016

currently, gogs is using the xorm/pq URL syntax as can be seen at:

https://github.com/gogits/gogs/blob/004fb30ebe403625b2315b284a85124611ba303b/models/models.go#L109

which translates to:

"postgres://git:password@/var/run/postgresql:5432/gogs?sslmode=disable"

but that does not seem to work with an unix domain socket.

but using the alternative syntax does work:

"user=git host=/var/run/postgresql port=5432 dbname=gogs sslmode=disable"

can gogs use the alternative syntax instead?

@merlin-tc
Copy link

I'd be really interested in that too.

@unknwon
Copy link
Member

unknwon commented Jul 2, 2016

What do you mean by but that does not seem to work with an unix domain socket?

@unknwon unknwon added the status: needs feedback Tell me more about it label Jul 2, 2016
@rgl
Copy link
Author

rgl commented Jul 3, 2016

To connect to the unix domain socket you have to use the alternative syntax, the URL syntax does not work. Also, the alternative syntax works fine with non-unix domain sockets.

@unknwon
Copy link
Member

unknwon commented Jul 3, 2016

How can I find docs about connection string? I remember "user=git host=/var/run/postgresql port=5432 dbname=gogs sslmode=disable" is deprecated way and I don't think PostgreSQL guys not even support unix in new connection string format?

@unknwon
Copy link
Member

unknwon commented Jul 3, 2016

Fount it: https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING

Also, you still have port number with unix socket seems wrong anyway?

@unknwon unknwon added 🔨 enhancement Make it better, faster 👋 good first issue Good for newcomers and removed status: needs feedback Tell me more about it labels Jul 3, 2016
@unknwon unknwon added this to the 0.10.0 milestone Jul 3, 2016
@rgl
Copy link
Author

rgl commented Jul 3, 2016

Having the "port number" is correct as postgres actually uses it. Its described on the link you've found:

port
Port number to connect to at the server host, or socket file name extension for Unix-domain connections.

@unknwon
Copy link
Member

unknwon commented Jul 3, 2016

OK... good to know. Anyway we have found the cause.

@mcheng89
Copy link
Contributor

mcheng89 commented Jul 3, 2016

From Unknwon's link:

Note, however, that the slash is a reserved character in the hierarchical part of the URI. So, to specify a non-standard Unix-domain socket directory, either omit the host specification in the URI and specify the host as a parameter, or percent-encode the path in the host component of the URI:

postgresql:///dbname?host=/var/lib/postgresql
postgresql://%2Fvar%2Flib%2Fpostgresql/dbname

Try escaping the slashes :)

@unknwon unknwon changed the title be able to connect to the postgres unix domain socket Able to connect to the postgres unix domain socket Aug 11, 2016
@unknwon unknwon changed the title Able to connect to the postgres unix domain socket Able to connect to the postgres unix socket Aug 11, 2016
@unknwon unknwon removed the 👋 good first issue Good for newcomers label Aug 11, 2016
@unknwon unknwon self-assigned this Aug 11, 2016
@unknwon unknwon added the status: needs feedback Tell me more about it label Aug 11, 2016
@unknwon
Copy link
Member

unknwon commented Aug 11, 2016

Patch has pushed to fix this issue, please test on develop branch.

@unknwon unknwon closed this as completed Aug 15, 2016
@rgl
Copy link
Author

rgl commented Aug 15, 2016

Thanks! Works fine at rgl/gogs-vagrant@e3de5a3 :-)

ethantkoenig pushed a commit to ethantkoenig/gogs that referenced this issue Nov 30, 2017
* govendor update code.gitea.io/git

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>

* Greatly improve memory usage

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
ethantkoenig referenced this issue in unfoldingWord/dcs Dec 16, 2017
* govendor update code.gitea.io/git

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>

* Greatly improve memory usage

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 enhancement Make it better, faster status: needs feedback Tell me more about it
Projects
None yet
Development

No branches or pull requests

4 participants