Thread: No connection could be made because the target machine actively refused it...

Hi,

I've installed PostgreSQL 9.2 (client and server) on a local Windows desktop and can run pgAdmin to see the postgres database.
However, now I'm trying to install a sample database to have a play with some queries etc...
I'm using psql, connecting to postgres on localhost as the postgres user and running the following command:

postgres# CREATE DATABASE dvdrental;
postgres# pg_restore --dbname=dvdrental --verbose dvdrental.tar

Nothing happens, and in the postgres log I get the following error:

2013-05-30 20:57:07 BST LOG:  incomplete startup packet
2013-05-30 20:57:45 BST LOG:  could not receive data from client: No connection could be made because the target machine actively refused it.

I've googled this error and it seems that it is probably something to do with my pg_hba.conf file.
I have tried each of the following entries and reloaded the file each time (pg_ctl reload), but to no avail:

# IPv4 local connections:
host     all             all         255.255.255.255/0             trust
host    all             all             127.0.0.1/32            trust
host    all             all             0.0.0.0/0               trust
local   all             all                                     trust

I also have 'listen_addresses = '*'' in my postgresql.conf file.

Can somebody please put me out of my misery and tell me what the entry should be when trying to access the server from a client on the same host?

Many thanks.

> postgres# CREATE DATABASE dvdrental;
> postgres# pg_restore --dbname=dvdrental --verbose dvdrental.tar
>

It appears that you are running pg_restore inside psql. Have you tried
running it in shell and not psql?


--
Amit Langote


Hi Amit,

Yes, you're absolutely right. I was running the commands in psql rather than the shell.
It wasn't obvious from the tutorial that I was following that I was supposed to run the pg_restore command from the shell and not psql.
Strange that running that command in psql never gave me any form of error and that the log was showing an error of 'No connection could be made because the target machine actively refused it'.
Anyway, I can run queries now and I'm starting to get acquainted with the environment, so thanks very much for your help.

Regards,
Frank.


---------- Forwarded message ----------
From: Amit Langote <amitlangote09@gmail.com>
Date: 31 May 2013 05:10
Subject: Re: [NOVICE] No connection could be made because the target machine actively refused it...
To: Frank Moore <francis.moore@gmail.com>
Cc: "pgsql-novice@postgresql.org" <pgsql-novice@postgresql.org>


> postgres# CREATE DATABASE dvdrental;
> postgres# pg_restore --dbname=dvdrental --verbose dvdrental.tar
>

It appears that you are running pg_restore inside psql. Have you tried
running it in shell and not psql?


--
Amit Langote