# Is it possible to run PostgreSQL within IDX for development?

**URL:** <https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174>\
**Category:** Extensibility\
**Created:** [May 19, 2024, 12:52pm UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174 "2024-05-19T12:52:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aduyng](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/aduyng/32/157_2.png) [@aduyng](https://community.firebasestudio.dev/u/aduyng)\
**Post date:** [May 19, 2024, 12:52pm UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174/1 "2024-05-19T12:52:43Z")

</div>

The project I am working on uses PostgreSQL database and I am wondering if I can install PostgreSQL server on IDX for local development?

---

<div class="post-metadata">

**Author:** ![aduyng](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/aduyng/32/157_2.png) [@aduyng](https://community.firebasestudio.dev/u/aduyng)\
**Post date:** [May 19, 2024, 1:12pm UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174/2 "2024-05-19T13:12:51Z")

</div>

Found a solution:

1. add `pkgs.postgresql_14` to your list of packages and rebuild your environment. All postgres server commands are available.
2. init and start the db server like normal

```bash
# create pgdata folder
mkdir ~/pgdata

# initialize db 
initdb --pgdata=~/pgdata --username=postgres

# try to connect
psql -U postgres

```

---

<div class="post-metadata">

**Author:** ![Tomasz\_Drobiszewski](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/tomasz_drobiszewski/32/2753_2.png) [@Tomasz\_Drobiszewski](https://community.firebasestudio.dev/u/Tomasz_Drobiszewski)\
**Post date:** [October 19, 2024, 10:11am UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174/3 "2024-10-19T10:11:46Z")

</div>

Instead of creating initdb etc. easier way is to add services.postgres

And add line below packages end like

```auto
services.postgres = {
  enable = true;   
  enableTcp = true;
};

```

---

<div class="post-metadata">

**Author:** ![Vandana\_Bachani](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/vandana_bachani/32/4423_2.png) [@Vandana\_Bachani](https://community.firebasestudio.dev/u/Vandana_Bachani)\
**Post date:** [March 10, 2025, 1:25am UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174/4 "2025-03-10T01:25:47Z")

</div>

Tried the steps here,  
But get the following error when trying to start the instance: FATAL: could not create lock file “/run/postgresql/.s.PGSQL.5432.lock”: No such file or directory  
EDIT: False alarm. Worked after creating the dir /run/postgresql

---

<div class="post-metadata">

**Author:** ![kirupa](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/kirupa/32/4_2.png) [@kirupa](https://community.firebasestudio.dev/u/kirupa)\
**Post date:** [March 10, 2025, 8:54pm UTC](https://community.firebasestudio.dev/t/is-it-possible-to-run-postgresql-within-idx-for-development/174/5 "2025-03-10T20:54:11Z")

</div>

We do have an official Postgres template that you could use (or look a the dev.nix file for to reproduce on a different workspace): [https://idx.google.com/new/postgres](https://idx.google.com/new/postgres)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/idxcommunity/original/2X/0/0cfa427036e72e2b3ed71ec5adbd4c1bb4a4ae17.jpeg)
