N
Neon2y ago
genetic-orange

Run Neon DB locally

I am loving using Neon DB however finding I am quickly using up my compute hours (free tier). I am not ready yet to pay for the service, so looking for a way that I can either mock our the DB (using something like MSW) or run a copy of the database locally. Does anyone have any tips or suggestions?
4 Replies
xenial-black
xenial-black2y ago
Hey @charklewis, Check out https://community.neon.tech/t/can-neon-be-self-hosted/51 if that helps?
compatible-crimson
compatible-crimson2y ago
Are you using the Neon branchig feature? On the Free Tier, the compute attached to your main branch is available 24/7. The compute hour usage you see on the project dashboard and the billing page (x/5h) is only for branch computes.
unwilling-turquoise
unwilling-turquoise2y ago
Why not just running a normal local PostgreSQL instance?, I dont know what machine you are using but with docker or a tool like https://dbngin.com/ or https://postgresapp.com/ you can easily get a connection string to do all your local stuff, migrations etc when times come just use the same migrations to be applied on your NeonDB
xenial-black
xenial-black2y ago
To run a postgres locally, you can use Docker. Here's how you'd do it:
docker run -p 5432:5432 --name my-postgres-container -e POSTGRES_PASSWORD=mysecretpassword -d postgres
docker run -p 5432:5432 --name my-postgres-container -e POSTGRES_PASSWORD=mysecretpassword -d postgres
This command creates a Docker container named my-postgres-container running a Postgres database. It maps port 5432 of the container to port 5432 of the host machine and sets the environment variable POSTGRES_PASSWORD to mysecretpassword. Next, let's connect to the Postgres instance using the psql command-line tool:
psql -h localhost -p 5432 -U postgres
psql -h localhost -p 5432 -U postgres
Here, -h specifies the host, -p specifies the port, and -U specifies the username. We are connecting to the default Postgres user named postgres.

Did you find this page helpful?