121

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?
vvvvv
  • 25,404
  • 19
  • 49
  • 81
pythondjango
  • 1,561
  • 2
  • 13
  • 23

7 Answers7

174

On my machine:

C:\Program Files\PostgreSQL\8.4\data\postgresql.conf
vvvvv
  • 25,404
  • 19
  • 49
  • 81
jonescb
  • 22,013
  • 7
  • 46
  • 42
  • I don't have that folder even though I ran the installer from http://www.stickpeople.com/projects/python/win-psycopg/ – pythondjango Dec 16 '10 at 21:24
  • 1
    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: http://www.postgresql.org/download/windows – jonescb Dec 16 '10 at 21:26
  • 2
    Just a side note: it usually not a very good idea to put application data into c:\Program Files –  Dec 16 '10 at 22:47
  • 2
    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). – Sam Oct 22 '13 at 02:46
38

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.

splash
  • 13,037
  • 1
  • 44
  • 67
  • This answer gave me some errors, so I found a working one here (version 9.3 64 bit with windows 8 64 bit) http://stackoverflow.com/a/17249527/2327328 – philshem Feb 04 '14 at 10:55
  • @philshem What kind of errors? `postgresql.conf`should be findable with this description. – splash Feb 04 '14 at 12:25
  • for every line: 'syntax error in file "C:/PostgreSQL/9.3/data/postgresql.conf" line 1, near token "@"' – philshem Feb 04 '14 at 12:40
  • 2
    @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](http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/misc/postgresql.conf.sample;hb=HEAD) – splash Feb 04 '14 at 12:55
  • This is a more generic answer than the accepted one. – Jayden Mar 23 '20 at 22:15
4

You can find it by following this path

C:\Program Files\PostgreSQL\13\data
Boris Kamtou
  • 454
  • 4
  • 5
1

On my machine:

C:\Program Files (x86)\OpenERP 6.1-20121026-233219\PostgreSQL\data
Dmitriy
  • 5,525
  • 12
  • 25
  • 38
Justi
  • 11
  • 1
1

you will get postgressql.conf file

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

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)
Pravind Kumar
  • 809
  • 1
  • 11
  • 10
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.

Saif Ali
  • 53
  • 3