Discussion:
Postgres IDENT auth problems...
(too old to reply)
Jens Porup
2004-07-01 03:38:44 UTC
Permalink
G'day,

I am trying to install Request Tracker (using Postgres) on a user-mode
linux server running Debian testing.

Installation (including database setup) runs flawlessly on my desktop
machine, but the postgres database setup fails on the server.

Correspondence on the Request Tracker mailing list seems to have
narrowed the problem to a postgres problem--if you can help me, it would
be much appreciated.

Here's the problem:

The request tracker database setup script dies trying to connect to
the database:

DBI connect('dbname=template1;host=localhost','rtuser',...) failed: could not
connect to server: Connection refused at /usr/sbin/rt-setup-database line 110

So I wrote a little Perl script to test this:

my $dsn = "dbi:Pg:dbname=template1";

###
### But this dies!!!
### my $dsn = "dbi:Pg:dbname=template1:host=localhost;";
###

my $dbh = DBI->connect($dsn, "rtuser", "wibble") or die "doh!\n";

For some reason specifying "host=localhost" in the $dsn causes everything to
die.

I can connect manually to the database, like so:

***@request-tracker:~# psql -d template1 -U rtuser -W
Password:
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.

But it fails if I specify the host:

***@request-tracker:~# psql -d template1 -U rtuser -h localhost -W
Password:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?

Now before you ask:

Yes, the following lines appear uncommented in my
/etc/postgresql/postgresql.conf:

tcpip_socket = true
port = 5432

But then:

***@request-tracker:~# netstat -auntp

shows postmaster running on a udp port???

udp 0 0 127.0.0.1:1042 127.0.0.1:1042 ESTABLISHED18375/postmaster

A server restart shows:

***@request-tracker:~# /etc/init.d/postgresql restart
Stopping PostgreSQL database server: autovacuumNo pg_autovacuum found running;
none killed.
postmaster.
Starting PostgreSQL database server: postmaster autovacuum.

What is pg_autovacuum anyway? I dunno....

And finally, I *do* have lines in my pg_hba.conf file (and yes, in the correct
order) to allow my user 'rtuser' to connect to template1:

host template1 rtuser 127.0.0.1 255.255.255.255 password
local template1 rtuser password
host rtdb rtuser 127.0.0.1 255.255.255.255 password
local rtdb rtuser password

The above four lines are the first uncommented lines in the file, as directed by
request tracker's INSTALL.Debian.

I should note that for whatever reason, Debian testing seems to
mistakenly read from /var/lib/postgres/data/pg_hba.conf instead of
/etc/postgresql/pg_hba.conf. I've symlinked the two, so this is not a
cause of the problem.

I have thoroughly and completely exhausted everything I can think of for
this problem. Request Tracker using postgres is up and running
fine--straight out of the box--on my Debian testing desktop, but not the
uml server.

Something about that host=localhost thing....

Any ideas?

Thanks,

Jens

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Jens Porup
2004-07-01 05:46:14 UTC
Permalink
Post by Jens Porup
The request tracker database setup script dies trying to connect to
DBI connect('dbname=template1;host=localhost','rtuser',...) failed: could not
connect to server: Connection refused at /usr/sbin/rt-setup-database line 110
<snip>
Post by Jens Porup
Yes, the following lines appear uncommented in my
tcpip_socket = true
port = 5432
shows postmaster running on a udp port???
udp 0 0 127.0.0.1:1042 127.0.0.1:1042 ESTABLISHED18375/postmaster
But can you nmap it? And that's not the right default port 5432...
Maybe it's some new feature I'm familiar with, or you've changed it.
Trust me, I am a postgres newbie... I'm not trying to do anything but a *very*
ordinary install!
What does nmap <ip> show?
***@request-tracker:~# nmap localhost

Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2004-07-01 15:39 EST
Interesting ports on localhost (127.0.0.1):
(The 1654 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
113/tcp open auth
515/tcp open printer

Nmap run completed -- 1 IP address (1 host up) scanned in 1.735 seconds
Post by Jens Porup
Stopping PostgreSQL database server: autovacuumNo pg_autovacuum found running;
none killed.
postmaster.
Starting PostgreSQL database server: postmaster autovacuum.
Sounds like a firewall to me.
My colleague here at work who built the user mode linux image I'm using
(the virtual "box") assures me there's no firewall installed.... how
would I check if there were?
Post by Jens Porup
And finally, I *do* have lines in my pg_hba.conf file (and yes, in the correct
Yeah, you'd see it as a different error, one about not having permission
psql: FATAL: no pg_hba.conf entry for host "10.0.0.2", user "postgres",
database "postgres", SSL off
Well, that helps eliminate one possibility anyway. Any more ideas?

Thanks,

Jens
Hope that helps.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Scott Marlowe
2004-07-01 15:25:29 UTC
Permalink
Post by Jens Porup
Post by Jens Porup
The request tracker database setup script dies trying to connect to
DBI connect('dbname=template1;host=localhost','rtuser',...) failed: could not
connect to server: Connection refused at /usr/sbin/rt-setup-database line 110
<snip>
Post by Jens Porup
Yes, the following lines appear uncommented in my
tcpip_socket = true
port = 5432
shows postmaster running on a udp port???
udp 0 0 127.0.0.1:1042 127.0.0.1:1042 ESTABLISHED18375/postmaster
But can you nmap it? And that's not the right default port 5432...
Maybe it's some new feature I'm familiar with, or you've changed it.
Trust me, I am a postgres newbie... I'm not trying to do anything but a *very*
ordinary install!
Well, something is quite wrong then. Find your postgresql.conf file and
see what port it is set to there. port 1042 is definitely not the
default port.

Also, try two things:

nmap -p 1042
psql -h 127.0.0.1 -p 1042

If nmap can see the port open, and psql can open it, then you can just
use it like that by specifying that port each time in your connect
string.
Post by Jens Porup
What does nmap <ip> show?
Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2004-07-01 15:39 EST
(The 1654 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
113/tcp open auth
515/tcp open printer
Nmap run completed -- 1 IP address (1 host up) scanned in 1.735 seconds
Post by Jens Porup
Stopping PostgreSQL database server: autovacuumNo pg_autovacuum found running;
none killed.
postmaster.
Starting PostgreSQL database server: postmaster autovacuum.
Sounds like a firewall to me.
My colleague here at work who built the user mode linux image I'm using
(the virtual "box") assures me there's no firewall installed.... how
would I check if there were?
IF the database is configured for port 1042, then it might not be a
firewall, just a misconfiguration of the database.



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Jens Porup
2004-07-02 02:38:54 UTC
Permalink
Post by Scott Marlowe
Post by Jens Porup
Post by Jens Porup
Yes, the following lines appear uncommented in my
tcpip_socket = true
port = 5432
shows postmaster running on a udp port???
udp 0 0 127.0.0.1:1042 127.0.0.1:1042 ESTABLISHED18375/postmaster
But can you nmap it? And that's not the right default port 5432...
Maybe it's some new feature I'm familiar with, or you've changed it.
Trust me, I am a postgres newbie... I'm not trying to do anything but a *very*
ordinary install!
Well, something is quite wrong then. Find your postgresql.conf file and
see what port it is set to there. port 1042 is definitely not the
default port.
nmap -p 1042
psql -h 127.0.0.1 -p 1042
***@request-tracker:~# nmap -p 1042

Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2004-07-02 12:36 EST
WARNING: No targets were specified, so 0 hosts scanned.
Nmap run completed -- 0 IP addresses (0 hosts up) scanned in 0.003 seconds

***@request-tracker:~# psql -h 127.0.0.1 -p 1042
No database specified
***@request-tracker:~#

*sigh*

I am beginning to think this is probably a build issue with the user mode linux
kernel I'm using. I'll look into that now.

Thanks,

Jens
Post by Scott Marlowe
If nmap can see the port open, and psql can open it, then you can just
use it like that by specifying that port each time in your connect
string.
Post by Jens Porup
What does nmap <ip> show?
Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2004-07-01 15:39 EST
(The 1654 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
113/tcp open auth
515/tcp open printer
Nmap run completed -- 1 IP address (1 host up) scanned in 1.735 seconds
Post by Jens Porup
Stopping PostgreSQL database server: autovacuumNo pg_autovacuum found running;
none killed.
postmaster.
Starting PostgreSQL database server: postmaster autovacuum.
Sounds like a firewall to me.
My colleague here at work who built the user mode linux image I'm using
(the virtual "box") assures me there's no firewall installed.... how
would I check if there were?
IF the database is configured for port 1042, then it might not be a
firewall, just a misconfiguration of the database.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Scott Marlowe
2004-07-01 05:33:04 UTC
Permalink
Post by Jens Porup
The request tracker database setup script dies trying to connect to
DBI connect('dbname=template1;host=localhost','rtuser',...) failed: could not
connect to server: Connection refused at /usr/sbin/rt-setup-database line 110
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
psql: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?
Yes, the following lines appear uncommented in my
tcpip_socket = true
port = 5432
shows postmaster running on a udp port???
udp 0 0 127.0.0.1:1042 127.0.0.1:1042 ESTABLISHED18375/postmaster
But can you nmap it? And that's not the right default port 5432...
Maybe it's some new feature I'm familiar with, or you've changed it.

What does nmap <ip> show?
Post by Jens Porup
Stopping PostgreSQL database server: autovacuumNo pg_autovacuum found running;
none killed.
postmaster.
Starting PostgreSQL database server: postmaster autovacuum.
Sounds like a firewall to me.
Post by Jens Porup
What is pg_autovacuum anyway? I dunno....
Coolest thing since sliced bread? It's a process that comes along and
cleans house in the back ground, without putting the onus of keeping the
database well cleaned on the average user.
Post by Jens Porup
And finally, I *do* have lines in my pg_hba.conf file (and yes, in the correct
host template1 rtuser 127.0.0.1 255.255.255.255 password
local template1 rtuser password
host rtdb rtuser 127.0.0.1 255.255.255.255 password
local rtdb rtuser password
Yeah, you'd see it as a different error, one about not having permission
to connect, like:

psql: FATAL: no pg_hba.conf entry for host "10.0.0.2", user "postgres",
database "postgres", SSL off

Hope that helps.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Jens Porup
2004-07-01 06:25:34 UTC
Permalink
Oh, almost forgot:

Some log errors that might help:

From /var/log/postgresql/autovacuum_log:

[2004-07-01 01:31:59 PM] Error: GUC variable stats_row_level must be enabled.
[2004-07-01 01:31:59 PM] Please fix the problems and try again.

After doing a server restart, this line always appends itself to the
/var/log/postgresql/postgres.log:

LOG: unexpected EOF on client connection

Do these help to clarify my problem at all?

Thanks,

Jens


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Oliver Elphick
2004-07-02 05:27:15 UTC
Permalink
Post by Jens Porup
[2004-07-01 01:31:59 PM] Error: GUC variable stats_row_level must be enabled.
[2004-07-01 01:31:59 PM] Please fix the problems and try again.
This is not relevant. Add:

stats_row_level = true

in /etc/postgresql/postgresql/conf


Autovacuum needs those statistics to work out what to vacuum.
--
Oliver Elphick ***@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Therefore being justified by faith, we have peace with
God through our Lord Jesus Christ." Romans 5:1


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ***@postgresql.org so that your
message can get through to the mailing list cleanly
Tom Lane
2004-07-01 13:09:15 UTC
Permalink
Post by Jens Porup
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
psql: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?
"Connection refused" means that you got a kernel-level rejection; the
postmaster never saw your request at all. AFAICS you did everything
right to ensure that the postmaster is listening on TCP port 5432
(though you may want to use netstat to reconfirm this). So that
leaves firewall-type problems. There is of course no separate firewall
box to blame, but there definitely can be kernel packet filters
getting in the way.

I know that recent Red Hat releases default to blocking port-5432
traffic (along with most other ports). I don't know Debian but I'd
bet it's the same story. You need to look to your ipchains or iptables
configuration.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ***@postgresql.org so that your
message can get through to the mailing list cleanly
Loading...