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•2y ago
compatible-crimson•2y 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•2y 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•2y ago
To run a postgres locally, you can use Docker.
Here's how you'd do it:
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:
Here, -h specifies the host, -p specifies the port, and -U specifies the username. We are connecting to the default Postgres user named postgres.