Pythagora-io / gpt-pilot

The first real AI developer
Other
31.83k stars 3.2k forks source link

psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061) #1

Closed akamalov closed 1 year ago

akamalov commented 1 year ago

Environment:

Windows

Problem:

(gpt-pilot) D:\AI\gpt-pilot\pilot>python main.py
Traceback (most recent call last):
  File "D:\AI\gpt-pilot\pilot\main.py", line 31, in <module>
    args = init()
           ^^^^^^
  File "D:\AI\gpt-pilot\pilot\main.py", line 17, in init
    create_database()
  File "D:\AI\gpt-pilot\pilot\database\database.py", line 396, in create_database
    conn = psycopg2.connect(
           ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\psycopg2\__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061)
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061)
        Is the server running on that host and accepting TCP/IP connections?

(gpt-pilot) D:\AI\gpt-pilot\pilot>
Captain-Bacon commented 1 year ago

You need to install Postgres SQL.

Long story short - install Postgres, get it setup, start the service, get the username and password and edit the .env file for the DB entries to be those credentials.

Then it all started working for me!

I installed it from here>> https://www.postgresql.org/download/macosx/ as I have a Mac, and used the homebrew install.

I then ran these commands: brew install postgresql createuser -s postgres brew services restart postgresql

taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

Then ran the command 'psql postgres', taken from here>> https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/

Then ran the \du command, taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

This told me the user name for the database. I then changed the 'admin' name in the .env file to the user name from the database, and changed the password to my password (or blank if you don't have one)

akamalov commented 1 year ago

Ah! Thank you so much. Is it possible to update README file to reflect the prerequisites?

On Tue, Aug 22, 2023, 11:48 PM Captain-Bacon @.***> wrote:

You need to install Postgres SQL.

Long story short - install Postgres, get it setup, start the service, get the username and password and edit the .env file for the DB entries to be those credentials.

Then it all started working for me!

I installed it from here>> https://www.postgresql.org/download/macosx/ as I have a Mac, and used the homebrew install.

I then ran these commands: brew install postgresql createuser -s postgres brew services restart postgresql

taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

Then ran the command 'psql postgres', taken from here>> https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/

Then ran the \du command, taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

This told me the user name for the database. I then changed the 'admin' name in the .env file to the user name from the database, and changed the password to my password (or blank if you don't have one)

— Reply to this email directly, view it on GitHub https://github.com/Pythagora-io/gpt-pilot/issues/1#issuecomment-1689237826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4FDSMI7FHJ6BOUVD7NJMDXWV4QHANCNFSM6AAAAAA32HCQII . You are receiving this because you authored the thread.Message ID: @.***>

akamalov commented 1 year ago

Just to add to it, why database is a requirement? Is it to keep a state ?

Captain-Bacon commented 1 year ago

I believe so yes. I think the original idea was that you still run the program without the database, and only require it if you were to save state and things like that (reading between the lines from the screen prompts), but there's a check at startup that requires it to be running, so you have to install it anyway.

mrshehzad1 commented 1 year ago

i was getting the same error thanks for your solution because there was no pre-requisite PostgreSQL mentioned in MD file.

Captain-Bacon commented 1 year ago

Just to add to it, why database is a requirement? Is it to keep a state ?

I've been going through it and the answer is 'yes'. Whenever a 'dev step' is referenced in the app then it causes a save_state to be run. This is saved as a line entry in the Posgres database. This can then be retrieved later and it can then continue from that state. This means that if you have an error then you can go back to any previous step and reissue new commands etc - it's pretty handy.

akamalov commented 1 year ago

Excellent, so you are saying that additional features can be built or layered up on over time? If 'yes', would you mind adding an example or two on how to pick up where one left from? Also, do you think it would make sense to add a 'backend', for example, instead of DB, using Azure blob (so, anyone with an access to a blob can pick up where it was left off, much like Terraform)?

Thank you.

On Sun, Aug 27, 2023, 6:52 PM Captain-Bacon @.***> wrote:

Just to add to it, why database is a requirement? Is it to keep a state ?

I've been going through it and the answer is 'yes'. Whenever a 'dev step' is referenced in the app then it causes a save_state to be run. This is saved as a line entry in the Posgres database. This can then be retrieved later and it can then continue from that state. This means that if you have an error then you can go back to any previous step and reissue new commands etc - it's pretty handy.

— Reply to this email directly, view it on GitHub https://github.com/Pythagora-io/gpt-pilot/issues/1#issuecomment-1694782321, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4FDSPERSZKOCNM6MYQEGDXXPFUVANCNFSM6AAAAAA32HCQII . You are receiving this because you authored the thread.Message ID: @.***>

Captain-Bacon commented 1 year ago

Excellent, so you are saying that additional features can be built or layered up on over time? If 'yes', would you mind adding an example or two on how to pick up where one left from? Also, do you think it would make sense to add a 'backend', for example, instead of DB, using Azure blob (so, anyone with an access to a blob can pick up where it was left off, much like Terraform)?

The simple answer is yes, but I don't think that's what it's designed for. For example I am plagued by max_token errors, so this allows me to go back to a few dev_steps earlier and try something different, or even the same sometimes because the AI will give different results depending on the complexity of the task that it's attempting.

You can use this to make adjustments. For example:

When it says 'do you want to run this, press r' , then you give it feedback. The expectation is that you tell it about the errors or lack thereof, however I've also used it when it's got stuck in a loop to tell it what I want it to do to fix something - given it a snippet of code etc.. You can use this feedback to ask it to introduce other functions etc., as per your suggestion.

When you start a new development it gives you an app_id. If you want to resume then you run it as

Python main.py app_id=the_long_app_id_code

If you want to start from a different dev_step then you run

Python main.py app_id=the_long_app_id_code dev_step=step_number

To find the Dev steps then look back through the console output and find the yellow/orange Dev step number. I often have to go back 10, 20 or 30+ Dev steps to get a working step to resume from. You can also find the Dev steps and the app_id from the PosgresDB - I used PGAdmin (I think that's what it's called), which gives a GUI for you.

The Dev steps positions are stored as JSON files which tell it where it was, what it was doing at the last save etc.. I've tried amending the JSON to change what it was about to start doing or thought it had done, but haven't had any luck with doing so yet.

I've thought about your idea of being able to share Dev points myself. I've noticed that the files that are in the Workspace that it's using also get amended back to that save-point too, which is great, bit I haven't looked into where they are stored yet, but they're presumably in the DB too. I don't know what Terraform is, so can't comment on that.

FWIW I'm not a coder, I don't know what a blob is, all my 'coding' is done with GPT historically, I'm just stubborn and absolutely desperate for some of my ideas to be realised in software, plus ADHD hyperfocus/obsession. I'm learning, but I can't pretend to know what I'm talking about in the larger scheme of things, so please take what I'm saying with a pinch of salt.

Also try looking up Cursor.so - it's unbelievablely useful - it's a VSCode fork with GPT built in as both chat and also code editor and generation - FAR better than any extension.

Just be careful - I've racked up over $60 dollars a day of GPT-4 calls using cursor and GPT-Pilot and that's around all the other things in my life over the weekend!

I hope that's useful to you though. If you get any further or have any tips as you progress then please do let me know!

LeonOstrez commented 1 year ago

You need to install Postgres SQL.

Long story short - install Postgres, get it setup, start the service, get the username and password and edit the .env file for the DB entries to be those credentials.

Then it all started working for me!

I installed it from here>> https://www.postgresql.org/download/macosx/ as I have a Mac, and used the homebrew install.

I then ran these commands: brew install postgresql createuser -s postgres brew services restart postgresql

taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

Then ran the command 'psql postgres', taken from here>> https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/

Then ran the \du command, taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist

This told me the user name for the database. I then changed the 'admin' name in the .env file to the user name from the database, and changed the password to my password (or blank if you don't have one)

that is correct. Thank you for your answer, we will definitely add it to readme soon.

Ah! Thank you so much. Is it possible to update README file to reflect the prerequisites? On Tue, Aug 22, 2023, 11:48 PM Captain-Bacon @.> wrote: You need to install Postgres SQL. Long story short - install Postgres, get it setup, start the service, get the username and password and edit the .env file for the DB entries to be those credentials. Then it all started working for me! I installed it from here>> https://www.postgresql.org/download/macosx/ as I have a Mac, and used the homebrew install. I then ran these commands: brew install postgresql createuser -s postgres brew services restart postgresql taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist Then ran the command 'psql postgres', taken from here>> https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/ Then ran the \du command, taken from here>> https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist This told me the user name for the database. I then changed the 'admin' name in the .env file to the user name from the database, and changed the password to my password (or blank if you don't have one) — Reply to this email directly, view it on GitHub <#1 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4FDSMI7FHJ6BOUVD7NJMDXWV4QHANCNFSM6AAAAAA32HCQII . You are receiving this because you authored the thread.Message ID: @.>

yes, we will add it soon and i will update this issue.

Just to add to it, why database is a requirement? Is it to keep a state ?

yes, we track progress of the app development. There are multiple reasons for that, like continuing app development if you had to stop at any point or app crashed, going back to specific step so you can change some later steps in development, easier debugging, for future we will add functionality to update project (change some things in existing project or add new features and so on)...

Excellent, so you are saying that additional features can be built or layered up on over time? If 'yes', would you mind adding an example or two on how to pick up where one left from? Also, do you think it would make sense to add a 'backend', for example, instead of DB, using Azure blob (so, anyone with an access to a blob can pick up where it was left off, much like Terraform)?

The simple answer is yes, but I don't think that's what it's designed for. For example I am plagued by max_token errors, so this allows me to go back to a few dev_steps earlier and try something different, or even the same sometimes because the AI will give different results depending on the complexity of the task that it's attempting.

You can use this to make adjustments. For example:

When it says 'do you want to run this, press r' , then you give it feedback. The expectation is that you tell it about the errors or lack thereof, however I've also used it when it's got stuck in a loop to tell it what I want it to do to fix something - given it a snippet of code etc.. You can use this feedback to ask it to introduce other functions etc., as per your suggestion.

When you start a new development it gives you an app_id. If you want to resume then you run it as

Python main.py app_id=the_long_app_id_code

If you want to start from a different dev_step then you run

Python main.py app_id=the_long_app_id_code dev_step=step_number

To find the Dev steps then look back through the console output and find the yellow/orange Dev step number. I often have to go back 10, 20 or 30+ Dev steps to get a working step to resume from. You can also find the Dev steps and the app_id from the PosgresDB - I used PGAdmin (I think that's what it's called), which gives a GUI for you.

The Dev steps positions are stored as JSON files which tell it where it was, what it was doing at the last save etc.. I've tried amending the JSON to change what it was about to start doing or thought it had done, but haven't had any luck with doing so yet.

I've thought about your idea of being able to share Dev points myself. I've noticed that the files that are in the Workspace that it's using also get amended back to that save-point too, which is great, bit I haven't looked into where they are stored yet, but they're presumably in the DB too. I don't know what Terraform is, so can't comment on that.

FWIW I'm not a coder, I don't know what a blob is, all my 'coding' is done with GPT historically, I'm just stubborn and absolutely desperate for some of my ideas to be realised in software, plus ADHD hyperfocus/obsession. I'm learning, but I can't pretend to know what I'm talking about in the larger scheme of things, so please take what I'm saying with a pinch of salt.

Also try looking up Cursor.so - it's unbelievablely useful - it's a VSCode fork with GPT built in as both chat and also code editor and generation - FAR better than any extension.

Just be careful - I've racked up over $60 dollars a day of GPT-4 calls using cursor and GPT-Pilot and that's around all the other things in my life over the weekend!

I hope that's useful to you though. If you get any further or have any tips as you progress then please do let me know!

everything you said was correct, thank you for that answer and helping out. We will make sure to update readme with more details and just a teaser, very soon we will launch VS Code extension for GPT-Pilot!

LeonOstrez commented 1 year ago

requirements added to readme