# Pg\_ctl: could not start server

**URL:** <https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253>\
**Category:** New to AiiDA\
**Created:** [February 8, 2024, 7:40pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253 "2024-02-08T19:40:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkarkee](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@rkarkee](https://aiida.discourse.group/u/rkarkee)\
**Post date:** [February 8, 2024, 7:40pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/1 "2024-02-08T19:40:57Z")

</div>

Hi all,

I am new to aiida and I have installed in local directory of HPC. I installed through conda.  
I am having this pg\_ctl: could not start server.

I did the following:  
**(aiidaENV) rkarkee@ch-fe1:~\> initdb -D /lustre/scratch5/$USER/aiidaDB**  
The files belonging to this database system will be owned by user “rkarkee”.  
This user must also own the server process.

The database cluster will be initialized with locale “en\_US.UTF-8”.  
The default database encoding has accordingly been set to “UTF8”.  
The default text search configuration will be set to “english”.

Data page checksums are disabled.

initdb: error: directory “/lustre/scratch5/rkarkee/aiidaDB” exists but is not empty  
initdb: hint: If you want to create a new database system, either remove or empty the directory “/lustre/scratch5/rkarkee/aiidaDB” or run initdb with an argument other than “/lustre/scratch5/rkarkee/aiidaDB”.

Then:  
**(aiidaENV) rkarkee@ch-fe1:~\> pg\_ctl -D /lustre/scratch5/$USER/aiidaDB -l /lustre/scratch5/$USER/aiidaLOG start**  
waiting for server to start… stopped waiting  
pg\_ctl: could not start server  
Examine the log output.

Then when I checked the log output, I find:  
2024-02-08 12:06:41.292 MST [142870] LOG: starting PostgreSQL 15.1 on x86\_64-conda-linux-gnu, compiled by x86\_64-conda-linux-gnu-cc (conda-forge gcc 11.3.0-19) 11.3.0, 64-bit  
2024-02-08 12:06:41.294 MST [142870] LOG: could not bind IPv4 address “127.0.0.1”: Address already in use  
2024-02-08 12:06:41.294 MST [142870] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.  
2024-02-08 12:06:41.294 MST [142870] WARNING: could not create listen socket for “localhost”  
2024-02-08 12:06:41.315 MST [142870] FATAL: could not create any TCP/IP sockets  
2024-02-08 12:06:41.317 MST [142870] LOG: database system is shut down  
2024-02-08 12:07:08.210 MST [154652] LOG: starting PostgreSQL 15.1 on x86\_64-conda-linux-gnu, compiled by x86\_64-conda-linux-gnu-cc (conda-forge gcc 11.3.0-19) 11.3.0, 64-bit  
2024-02-08 12:07:08.211 MST [154652] LOG: could not bind IPv4 address “127.0.0.1”: Address already in use  
2024-02-08 12:07:08.211 MST [154652] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.  
2024-02-08 12:07:08.211 MST [154652] WARNING: could not create listen socket for “localhost”  
2024-02-08 12:07:08.211 MST [154652] FATAL: could not create any TCP/IP sockets  
2024-02-08 12:07:08.212 MST [154652] LOG: database system is shut down

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [February 9, 2024, 8:34am UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/2 "2024-02-09T08:34:21Z")

</div>

Please check the answer in this thread: [Cannot connect to database - #4 by jgarridoa](https://aiida.discourse.group/t/cannot-connect-to-database/240/4)

It seems like port 5432 is already in use on your system (probably another instance of PostgreSQL is already running). Change the port when launching your server, and then make sure to update the value in your `config.json`. You find the configuration folder in which you find that file by running `verdi profile list`.

---

<div class="post-metadata">

**Author:** ![rkarkee](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@rkarkee](https://aiida.discourse.group/u/rkarkee)\
**Post date:** [February 10, 2024, 5:33pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/3 "2024-02-10T17:33:59Z")

</div>

Hi @sphuber  
I followed the link as you suggested and did the following:  
**pg\_ctl -D /lustre/scratch5/rkarkee/aiidaDB -o “-F -p 5433” -l logfile start**  
Server then started

I also updated the config.json  
Then I did  
**rabbitmq-server -detached**

and finally

**(aiidaENV) rkarkee@ch-fe2:~\> verdi daemon start 2**  
Critical: Could not connect to database: (psycopg2.OperationalError) connection to server at “localhost” (127.0.0.1), port 5433 failed: FATAL: role “aiida\_qs\_rkarkee\_20554bcc4bead70a3479c4ef8d5f1f4e” does not exist

(Background on this error at: [Error Messages — SQLAlchemy 2.0 Documentation](https://sqlalche.me/e/20/e3q8))

My verdi status looks following:  
**(aiidaENV) rkarkee@ch-fe2:~\> verdi status**  
✔ version: AiiDA v2.5.1  
✔ config: /users/rkarkee/.aiida  
✔ profile: rkarkee  
✘ storage: Unable to connect to profile’s storage.  
Error: UnreachableStorage: Could not connect to database: (psycopg2.OperationalError) connection to server at “localhost” (127.0.0.1), port 5433 failed: FATAL: role “aiida\_qs\_rkarkee\_20554bcc4bead70a3479c4ef8d5f1f4e” does not exist

(Background on this error at: [Error Messages — SQLAlchemy 2.0 Documentation](https://sqlalche.me/e/20/e3q8))  
✔ rabbitmq: Connected to RabbitMQ v3.8.14 as amqp://guest:guest@127.0.0.1:5672?heartbeat=600  
⏺ daemon: The daemon is not running.

How can I fix this?

Thanks a lot.

Best  
Rijan

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [February 10, 2024, 7:58pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/4 "2024-02-10T19:58:58Z")

</div>

As the error says, your PostgreSQL server does not have the role `aiida_qs_rkarkee_20554bcc4bead70a3479c4ef8d5f1f4e` which your profile defines. This may be due to you running the `verdi quicksetup` before with a different PSQL server up and running and now you are connecting to another one. There are two options:

1. Run `verdi quicksetup` again, creating a new profile using the new PSQL server
2. If you keep having issues with your PSQL server, why not try the recent feature of using a profile that doesn’t use PSQL. You can create such a profile as follows:

```auto
verdi profile setup core.sqlite_dos --profile new-profile --set-as-default

```

You can change the profile name of course. Note that this uses Sqlite instead of PSQL which is less performant. But it may be useful to just get you started for now

---

<div class="post-metadata">

**Author:** ![rkarkee](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@rkarkee](https://aiida.discourse.group/u/rkarkee)\
**Post date:** [February 10, 2024, 9:34pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/5 "2024-02-10T21:34:13Z")

</div>

Hi @sphuber  
I tried creating new setup again but got the same error.  
(aiidaENV) rkarkee@ch-fe2:~\> pg\_ctl -D /lustre/scratch5/rkarkee/aiidaDB -o “-F -p 5433” -l logfile start  
waiting for server to start… done  
server started  
(aiidaENV) rkarkee@ch-fe2:~\> verdi quicksetup  
Report: enter ? for help.  
Report: enter ! to ignore the default and set no value.  
Profile name [quicksetup]: newproject  
Email Address (for sharing data) [rkarkee@ucmerced.edu]:  
First name [Rijan]: Rkarkee  
Last name [Karkee]: Karkee  
Institution [UC Merced]:  
Unable to autodetect postgres setup.  
Please provide PostgreSQL connection info:  
postgres host [localhost]:  
postgres port [5432]: 5433  
postgres super user [postgres]:  
database [template1]:  
postgres password of {dsn\_new[“user”]} : test  
Report: initialising the profile storage.  
Report: initialising empty storage schema  
Report: Migrating to the head of the main branch  
Success: storage initialisation completed.  
Success: created new profile `newproject`.  
(aiidaENV) rkarkee@ch-fe2:~\> rabbitmq-server -detached  
(aiidaENV) rkarkee@ch-fe2:~\> verdi daemon start 2  
Critical: Could not connect to database: (psycopg2.OperationalError) connection to server at “localhost” (127.0.0.1), port 5433 failed: FATAL: database “rkarkee\_rkarkee\_20554bcc4bead70a3479c4ef8d5f1f4e” does not exist

(Background on this error at: [Error Messages — SQLAlchemy 2.0 Documentation](https://sqlalche.me/e/20/e3q8))

I then tried with second option, that seemed to have worked.

(aiidaENV) rkarkee@ch-fe2:~\> verdi status  
✔ version: AiiDA v2.5.1  
✔ config: /users/rkarkee/.aiida  
✔ profile: new-profile  
✔ storage: SqliteDosStorage[/users/rkarkee/.aiida/repository/sqlite\_dos\_1e8f6c59ad444aee8a6e5abb574e4857]: open,  
✔ rabbitmq: Connected to RabbitMQ v3.8.14 as amqp://guest:guest@127.0.0.1:5672?heartbeat=600  
✔ daemon: Daemon is running with PID 141169

I have created so many profiles.

I do not have all the permission , so I could not deleted via verdi profile delete

I saw in documentation it can be deleted manually via PostgreSQL. How can I do that?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/aiida/original/1X/c417197d3750949351575d03ed03f5e2ad32e649.png) [@system](https://aiida.discourse.group/u/system)\
**Post date:** [February 9, 2026, 9:34pm UTC](https://aiida.discourse.group/t/pg-ctl-could-not-start-server/253/6 "2026-02-09T21:34:41Z")

</div>

This topic was automatically closed 730 days after the last reply. New replies are no longer allowed.
