-
Notifications
You must be signed in to change notification settings - Fork 16
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
Any way to connect from localhost? #33
Comments
If you were connecting via WebSockets (by importing But: you're connecting via http. So I think you have two options: (1) You could use plain (2) You could run our open-source proxy configured to talk to a local Postgres DB. This is a bit more involved, but would look something like the following. In your app, you'll need to set the (new)
Then, set up the proxy like so: # install Rust if not already available
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# get and build the proxy
git clone https://github.com/neondatabase/neon.git
cd neon
cargo build --bin proxy
# still in `neon` directory, create a self-signed cert for *.localtest.me (see https://readme.localtest.me/)
openssl req -new -x509 -days 365 -nodes -text -out server.crt -keyout server.key -subj "/CN=*.localtest.me"
# start local postgres -- ensure you have an appropriate DB + user set up with either `trust` or `scram-sha-256` auth
# still in `neon` directory, run the proxy (substituting in an appropriate postgres:// connection string)
./target/debug/proxy -c server.crt -k server.key --auth-backend=postgres \
--auth-endpoint=postgres://user:password@db.localtest.me/main --wss=0.0.0.0:4444 # or: --wss='[::1]:4444'
# run your app, accepting the self-signed cert
NODE_TLS_REJECT_UNAUTHORIZED=0 node myfile.js I'm aware this is a bit painful, and we're looking into ways we can make this simpler. |
Thanks! |
@jawj a couple of things I ran into when trying to get neon http working locally:
Two options:
Soo yeah, overall quite a bit of work use local postgres with |
Thanks @marbemac.
|
❤️ this worked. |
Maybe this helps someone else that ends up here: I've taken the steps described in #33 (comment) and created a Docker compose project to simplify the setup process for a local neon proxy + PostgreSQL DB. You can find the repo here: https://github.com/TimoWilhelm/local-neon-http-proxy The container also includes a small Caddy reverse proxy to setup the upstream TLS connection so the code does not need to trust the self-signed certificate of the neon proxy. |
I would like to use an offline local instance of postgress while developing on my computer, I'm trying something like this:
But I keep getting an error that my uri is wrong
The text was updated successfully, but these errors were encountered: