Trouble using postgres sql in ubuntu 16.04
up vote
1
down vote
favorite
I am running Ubuntu 16.04 operating system and have recently installed postgres using the instructions given in https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04.
However, when I tried to use postgres using
snowbell@snowbell-Aspire-4738Z:/var/www$ sudo -i -u postgres
postgres@snowbell-Aspire-4738Z:~$ psql
I got the following error message
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
postgres@snowbell-Aspire-4738Z:~$ sudo -u postgres psql
postgres is not in the sudoers file. This incident will be reported.
In order to get away with this error, I tried using
snowbell@snowbell-Aspire-4738Z:~$ sudo -u postgres psql -p 5432 -h 127.0.0.1
As a result, I got the following error
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Any clues?
The output is as follows

Here is the Sample_error file blissini

ubuntu postgresql
|
show 3 more comments
up vote
1
down vote
favorite
I am running Ubuntu 16.04 operating system and have recently installed postgres using the instructions given in https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04.
However, when I tried to use postgres using
snowbell@snowbell-Aspire-4738Z:/var/www$ sudo -i -u postgres
postgres@snowbell-Aspire-4738Z:~$ psql
I got the following error message
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
postgres@snowbell-Aspire-4738Z:~$ sudo -u postgres psql
postgres is not in the sudoers file. This incident will be reported.
In order to get away with this error, I tried using
snowbell@snowbell-Aspire-4738Z:~$ sudo -u postgres psql -p 5432 -h 127.0.0.1
As a result, I got the following error
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Any clues?
The output is as follows

Here is the Sample_error file blissini

ubuntu postgresql
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
Is postgresql running? Tryps -ef | grep postgres. If not, look into/var/log/postgresql/postgresql-*-main.logfor startup errors.
– ridgy
Nov 20 '16 at 12:31
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18
|
show 3 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am running Ubuntu 16.04 operating system and have recently installed postgres using the instructions given in https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04.
However, when I tried to use postgres using
snowbell@snowbell-Aspire-4738Z:/var/www$ sudo -i -u postgres
postgres@snowbell-Aspire-4738Z:~$ psql
I got the following error message
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
postgres@snowbell-Aspire-4738Z:~$ sudo -u postgres psql
postgres is not in the sudoers file. This incident will be reported.
In order to get away with this error, I tried using
snowbell@snowbell-Aspire-4738Z:~$ sudo -u postgres psql -p 5432 -h 127.0.0.1
As a result, I got the following error
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Any clues?
The output is as follows

Here is the Sample_error file blissini

ubuntu postgresql
I am running Ubuntu 16.04 operating system and have recently installed postgres using the instructions given in https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04.
However, when I tried to use postgres using
snowbell@snowbell-Aspire-4738Z:/var/www$ sudo -i -u postgres
postgres@snowbell-Aspire-4738Z:~$ psql
I got the following error message
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
postgres@snowbell-Aspire-4738Z:~$ sudo -u postgres psql
postgres is not in the sudoers file. This incident will be reported.
In order to get away with this error, I tried using
snowbell@snowbell-Aspire-4738Z:~$ sudo -u postgres psql -p 5432 -h 127.0.0.1
As a result, I got the following error
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Any clues?
The output is as follows

Here is the Sample_error file blissini

ubuntu postgresql
ubuntu postgresql
edited Nov 21 '16 at 11:19
asked Nov 19 '16 at 17:11
Upendra Pratap Singh
2311210
2311210
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
Is postgresql running? Tryps -ef | grep postgres. If not, look into/var/log/postgresql/postgresql-*-main.logfor startup errors.
– ridgy
Nov 20 '16 at 12:31
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18
|
show 3 more comments
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
Is postgresql running? Tryps -ef | grep postgres. If not, look into/var/log/postgresql/postgresql-*-main.logfor startup errors.
– ridgy
Nov 20 '16 at 12:31
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
Is postgresql running? Try
ps -ef | grep postgres. If not, look into /var/log/postgresql/postgresql-*-main.logfor startup errors.– ridgy
Nov 20 '16 at 12:31
Is postgresql running? Try
ps -ef | grep postgres. If not, look into /var/log/postgresql/postgresql-*-main.logfor startup errors.– ridgy
Nov 20 '16 at 12:31
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
If you have exhausted what has been suggested in the comments then the error itself may be related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Ensure that
postgresqlservice is running, usingsudo service postgresql startRun
pg_lsclustersfrom your terminal- Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, for example:pg_ctlcluster 9.6 main startIf something is wrong, then
postgresqlwill generate a log, that can be accessed on/var/log/postgresql/postgresql-<version>-main.log, for example:
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Whatever error the log gives you, fix it and restart postgresql service through:
sudo service postgresql restart
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f324546%2ftrouble-using-postgres-sql-in-ubuntu-16-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If you have exhausted what has been suggested in the comments then the error itself may be related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Ensure that
postgresqlservice is running, usingsudo service postgresql startRun
pg_lsclustersfrom your terminal- Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, for example:pg_ctlcluster 9.6 main startIf something is wrong, then
postgresqlwill generate a log, that can be accessed on/var/log/postgresql/postgresql-<version>-main.log, for example:
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Whatever error the log gives you, fix it and restart postgresql service through:
sudo service postgresql restart
add a comment |
up vote
1
down vote
If you have exhausted what has been suggested in the comments then the error itself may be related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Ensure that
postgresqlservice is running, usingsudo service postgresql startRun
pg_lsclustersfrom your terminal- Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, for example:pg_ctlcluster 9.6 main startIf something is wrong, then
postgresqlwill generate a log, that can be accessed on/var/log/postgresql/postgresql-<version>-main.log, for example:
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Whatever error the log gives you, fix it and restart postgresql service through:
sudo service postgresql restart
add a comment |
up vote
1
down vote
up vote
1
down vote
If you have exhausted what has been suggested in the comments then the error itself may be related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Ensure that
postgresqlservice is running, usingsudo service postgresql startRun
pg_lsclustersfrom your terminal- Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, for example:pg_ctlcluster 9.6 main startIf something is wrong, then
postgresqlwill generate a log, that can be accessed on/var/log/postgresql/postgresql-<version>-main.log, for example:
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Whatever error the log gives you, fix it and restart postgresql service through:
sudo service postgresql restart
If you have exhausted what has been suggested in the comments then the error itself may be related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Ensure that
postgresqlservice is running, usingsudo service postgresql startRun
pg_lsclustersfrom your terminal- Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, for example:pg_ctlcluster 9.6 main startIf something is wrong, then
postgresqlwill generate a log, that can be accessed on/var/log/postgresql/postgresql-<version>-main.log, for example:
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Whatever error the log gives you, fix it and restart postgresql service through:
sudo service postgresql restart
answered yesterday
Daniel
165212
165212
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f324546%2ftrouble-using-postgres-sql-in-ubuntu-16-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you post the output: of sudo netstat -lntp ?
– blissini
Nov 19 '16 at 17:39
see the snapshot for the output
– Upendra Pratap Singh
Nov 20 '16 at 10:47
Is postgresql running? Try
ps -ef | grep postgres. If not, look into/var/log/postgresql/postgresql-*-main.logfor startup errors.– ridgy
Nov 20 '16 at 12:31
Yes, postgresql is working Following is the output
– Upendra Pratap Singh
Nov 20 '16 at 14:18
snowbell@snowbell-Aspire-4738Z:~$ ps -ef | grep postgres snowbell 5425 5411 0 19:49 pts/9 00:00:00 grep --color=auto postgres
– Upendra Pratap Singh
Nov 20 '16 at 14:18