+ use different data areas and different communication ports (see below).
+
A data area is created with
endterm="app-initdb-title">.
Specifies the TCP/IP hostname or address on which the
postmaster is to listen for
- connections from client applications. Defaults to the value
- of the PGHOST environment variable, or if
- PGHOST is not set, it defaults to listening on
- all configured addresses (including localhost).
+ connections from client applications. Defaults to
+ listening on all configured addresses (including localhost).
- -k filename
+ -k directoryname
- Specifies the directory for Unix domain socket on which the
+ Specifies the directory of the Unix-domain socket on which the
postmaster is to listen for
- connections from client applications. Defaults to the value
- of the PGUNIXSOCKET environment variable, or if
- PGUNIXSOCKET is not set, then defaults to a
- file in /tmp.
+ connections from client applications. The default is normally
+ /tmp, but can be changed at build time.
connectDB() -- connect() failed: Connection refused
-Is the postmaster running (with -i) at 'server.joe.com' and accepting connections on TCP/IP port '5432'?
+Is the postmaster running (with -i) at 'server.joe.com' and accepting connections on TCP/IP port 5432?
This is the generic I couldn't find a server to talk
to failure. It looks like the above when TCP/IP
Unix-socket communication to a local postmaster:
connectDB() -- connect() failed: No such file or directory
-Is the postmaster running at 'localhost' and accepting connections on Unix socket '5432'?
+Is the postmaster running locally and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
- UNIXSOCKET (string)
+ UNIX_SOCKET_DIRECTORY (string)
- Specifies the directory of the Unix domain socket on which the
+ Specifies the directory of the Unix-domain socket on which the
postmaster is to listen for
- connections from client applications. Defaults to the value
- of the PGUNIXSOCKET environment variable, or if
- PGUNIXSOCKET is not set, then defaults to
- /tmp.
+ connections from client applications. The default is normally
+ /tmp, but can be changed at build time.
Specifies the TCP/IP hostname or address on which the
postmaster is to listen for
- connections from client applications. Defaults to the value
- of the PGHOST environment variable, or if
- PGHOST is not set, it defaults to listening on
- all configured addresses (including localhost).
-
- If you use a hostname do not try to run multiple instances of
-
postmaster on the same IP address
- but different ports. Doing so will result in them attempting
- (incorrectly) to use the same shared memory segments. Also,
- if you use a hostname, all of the host's IP addresses on which
-
postmaster instances are listening
- must be distinct in the two last octets.
-
- If you do not use this option, then each instance must listen
- on a different port.
+ connections from client applications. Defaults to
+ listening on all configured addresses (including localhost).
tcpip_socket = on
+ |
+ -k x
+ unix_socket_directory = x
+
+
|
-l
ssl = on
will need to set the
PGHOST environment
variable to the name
of the database server machine. The environment variable
-
PGPORT or PGUNIXSOCKET may also have to be set.
+
PGPORT may also have to be set.
The bottom line is this: if
you try to start an application program and it complains
that it cannot connect to the
postmaster,
% psql template1
-Connection to database 'postgres' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '5432'?
+psql: connectDBStart() -- connect() failed: No such file or directory
+ Is the postmaster running locally
+ and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
or
% psql -h localhost template1
-Connection to database 'postgres' failed.
-connectDB() failed: Is the postmaster running and accepting TCP/IP
- (with -i) connections at 'localhost' on port '5432'?
+psql: PQconnectPoll() -- connect() failed: Connection refused
+ Is the postmaster running (with -i) at 'localhost'
+ and accepting connections on TCP/IP port 5432?
it is usually because
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.196 2000/11/29 22:04:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.197 2000/11/30 23:20:51 tgl Exp $
*
* NOTES
*
NetServer = true;
break;
case 'k':
- /* Set PGUNIXSOCKET by hand. */
UnixSocketDir = optarg;
break;
#ifdef USE_SSL
printf(" -F turn fsync off\n");
printf(" -h HOSTNAME host name or IP address to listen on\n");
printf(" -i enable TCP/IP connections\n");
- printf(" -k FILENAME Unix domain socket location\n");
+ printf(" -k DIRECTORY Unix-domain socket location\n");
#ifdef USE_SSL
printf(" -l enable SSL connections\n");
#endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.151 2000/11/30 18:32:52 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.152 2000/11/30 23:20:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
+/* ----------
+ * connectFailureMessage -
+ * create a friendly error message on connection failure.
+ * ----------
+ */
+static void
+connectFailureMessage(PGconn *conn, const char *caller, int errorno)
+{
+#ifdef HAVE_UNIX_SOCKETS
+ if (conn->raddr.sa.sa_family == AF_UNIX)
+ printfPQExpBuffer(&conn->errorMessage,
+ "%s -- connect() failed: %s\n"
+ "\tIs the postmaster running locally\n"
+ "\tand accepting connections on Unix socket '%s'?\n",
+ caller,
+ strerror(errorno),
+ conn->raddr.un.sun_path);
+ else
+#endif
+ printfPQExpBuffer(&conn->errorMessage,
+ "%s -- connect() failed: %s\n"
+ "\tIs the postmaster running (with -i) at '%s'\n"
+ "\tand accepting connections on TCP/IP port %s?\n",
+ caller,
+ strerror(errorno),
+ conn->pghost ? conn->pghost : "localhost",
+ conn->pgport);
+}
+
+
/* ----------
* connectDBStart -
* Start to make a connection to the backend so it is ready to receive
else
{
/* Something's gone wrong */
- printfPQExpBuffer(&conn->errorMessage,
- "connectDBStart() -- connect() failed: %s\n"
- "\tIs the postmaster running%s at '%s'\n"
- "\tand accepting connections on %s '%s'?\n",
- strerror(errno),
- (family == AF_INET) ? " (with -i)" : "",
- conn->pghost ? conn->pghost : "localhost",
- (family == AF_INET) ?
- "TCP/IP port" : "Unix socket",
- (family == AF_UNIX && conn->pgunixsocket) ?
- conn->pgunixsocket : conn->pgport);
+ connectFailureMessage(conn, "connectDBStart()", errno);
goto connect_errReturn;
}
}
* see connect failures at this point, so provide a
* friendly error message.
*/
- printfPQExpBuffer(&conn->errorMessage,
- "PQconnectPoll() -- connect() failed: %s\n"
- "\tIs the postmaster running%s at '%s'\n"
- "\tand accepting connections on %s '%s'?\n",
- strerror(optval),
- (conn->raddr.sa.sa_family == AF_INET) ? " (with -i)" : "",
- conn->pghost ? conn->pghost : "localhost",
- (conn->raddr.sa.sa_family == AF_INET) ?
- "TCP/IP port" : "Unix socket",
- (conn->raddr.sa.sa_family == AF_UNIX && conn->pgunixsocket) ?
- conn->pgunixsocket : conn->pgport);
+ connectFailureMessage(conn, "PQconnectPoll()", optval);
goto error_return;
}