135

I'm receiving this message but I can't find the postgresql.conf file:

OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
    Is the server running on host "???" and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
    Is the server running on host "???" and accepting
    TCP/IP connections on port 5432?
1

7 Answers 7

193

On my machine:

C:\Program Files\PostgreSQL\8.4\data\postgresql.conf
Sign up to request clarification or add additional context in comments.

4 Comments

I don't have that folder even though I ran the installer from stickpeople.com/projects/python/win-psycopg
psycopg is used to connect to the Database server, it isn't the Database server itself. You want to install the server portion from here: postgresql.org/download/windows
Just a side note: it usually not a very good idea to put application data into c:\Program Files
For PostgreSQL 9.2 and probably the earlier versions in the 9.x series, it is located at the much more appropriate location of C:\ProgramData\PostgreSQL\9.2\data\postgresql.conf (at least with Windows 7 anyway).
40

postgresql.conf is located in PostgreSQL's data directory. The data directory is configured during the setup and the setting is saved as PGDATA entry in c:\Program Files\PostgreSQL\<version>\pg_env.bat, for example

    @ECHO OFF
    REM The script sets environment variables helpful for PostgreSQL
    
    @SET PATH="C:\Program Files\PostgreSQL\<version>\bin";%PATH%
    @SET PGDATA=D:\PostgreSQL\<version>\data
    @SET PGDATABASE=postgres
    @SET PGUSER=postgres
    @SET PGPORT=5432
    @SET PGLOCALEDIR=C:\Program Files\PostgreSQL\<version>\share\locale

Alternatively you can query your database with SHOW config_file; if you are a superuser.

6 Comments

This answer gave me some errors, so I found a working one here (version 9.3 64 bit with windows 8 64 bit) stackoverflow.com/a/17249527/2327328
@philshem What kind of errors? postgresql.confshould be findable with this description.
for every line: 'syntax error in file "C:/PostgreSQL/9.3/data/postgresql.conf" line 1, near token "@"'
@philshem the example in my answer is just the content of the mentioned pg_env.bat and not intended for use in postgresql.conf. The postgresql.conf file should exist in the PGDATA directory and looks like this: postgresql.conf.sample
This is a more generic answer than the accepted one.
|
5

You can find it by following this path

C:\Program Files\PostgreSQL\13\data

1 Comment

I had the same question, and this worked for me (version 16). My concern was that a regular windows search for the postgresql.conf file didn't locate it anywhere. For me, it was due to the data folder being behind admin rights. But the file was there and the installation worked. :)
1

On my machine:

C:\Program Files (x86)\OpenERP 6.1-20121026-233219\PostgreSQL\data

Comments

1

you will get postgressql.conf file

C:/programfiles/postgressql/14/data you will also get the pg_hba to check username password

Comments

0

PGDATA is assumed as ConfigDir under Postgresql, this works under docker and normal installation as well, this is default configuration until not changed explicitly.

on my docker PGDATA is configure as "/var/lib/postgresql/data" hence all configuration can be found under this directory.

#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

#data_directory = 'ConfigDir'       # use data in another directory
                # (change requires restart)
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
                # (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
                # (change requires restart)

# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = ''         # write an extra PID file
                # (change requires restart)

Comments

0

You can find your Postgres global config file using the following path:

  • Replace with the Postgres version you have installed.

    C:\Program Files\PostgreSQL<version>\data

This is usually the default location at installation.

However, if you are still unable to locate the file using the path try using file search in Windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.