Postgres changes file permissions to its detriment
Someone, please, please, please explain to me what the hell is going on here, and how I can fix this?
I'll let my console do the talking:
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:08 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# chmod 777 postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwsrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# chmod g-s postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwxrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:48 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# ls -l |grep post
drwxrwsr-x 2 postgres postgres 40 Jan 15 10:24 postgresql
permissions postgresql
add a comment |
Someone, please, please, please explain to me what the hell is going on here, and how I can fix this?
I'll let my console do the talking:
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:08 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# chmod 777 postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwsrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# chmod g-s postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwxrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:48 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# ls -l |grep post
drwxrwsr-x 2 postgres postgres 40 Jan 15 10:24 postgresql
permissions postgresql
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57
add a comment |
Someone, please, please, please explain to me what the hell is going on here, and how I can fix this?
I'll let my console do the talking:
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:08 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# chmod 777 postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwsrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# chmod g-s postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwxrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:48 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# ls -l |grep post
drwxrwsr-x 2 postgres postgres 40 Jan 15 10:24 postgresql
permissions postgresql
Someone, please, please, please explain to me what the hell is going on here, and how I can fix this?
I'll let my console do the talking:
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:08 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# chmod 777 postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwsrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# chmod g-s postgresql
root@worker2:/var/run# ls -l |grep post
drwxrwxrwx 2 postgres postgres 40 Jan 15 10:24 postgresql
root@worker2:/var/run# service postgresql start
* Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output:
2016-01-15 10:47:48 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
root@worker2:/var/run# ls -l |grep post
drwxrwsr-x 2 postgres postgres 40 Jan 15 10:24 postgresql
permissions postgresql
permissions postgresql
asked Jan 15 '16 at 19:47
Ernie DunbarErnie Dunbar
1112
1112
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57
add a comment |
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57
add a comment |
2 Answers
2
active
oldest
votes
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
sudo chown -R postgres:postgres /var/run/postgresql**
If the user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
add a comment |
I had the exact same problem. I still don't know what caused it, but as a workaround I changed the postgresql pid file directory and unix socket directory (although perhaps the former wasn't necessary). I will call this new directory /pg_workaround
in this answer.
mkdir /pg_workaround
chown postgres:postgres /pg_workaround
chmod 777 /pg_workaround
Then edit /etc/postgresql/<version>/main/postgresql.conf
and modify the following lines:
external_pid_file = '/pg_workaround/<version>-main.pid'
unix_socket_directory = '/pg_workaround'
(Replace /pg_workaround
with the desired location and <version>
with your actual postgres version.)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f721528%2fpostgres-changes-file-permissions-to-its-detriment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
sudo chown -R postgres:postgres /var/run/postgresql**
If the user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
add a comment |
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
sudo chown -R postgres:postgres /var/run/postgresql**
If the user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
add a comment |
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
sudo chown -R postgres:postgres /var/run/postgresql**
If the user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
sudo chown -R postgres:postgres /var/run/postgresql**
If the user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
answered Jan 15 '16 at 19:57
Saleh SalemSaleh Salem
111
111
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
add a comment |
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
Read my output carefully please. That's exactly what I did. What appears to be happening, is that Postgresql actually changes this file's permissions to not work with whatever user the Postgresql server is actually running with. (ie, not postgres, or the permissions above would actually work - yes, I've tested writing files as the postgres user in /var/run/postgresql)
– Ernie Dunbar
Jan 15 '16 at 21:00
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
I can see that you used chmod not chown!
– Saleh Salem
Jan 16 '16 at 21:21
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
root@worker2:/var/run# chown -R postgres:postgres /var/run/postgresql root@worker2:/var/run# service postgresql start * Starting PostgreSQL 9.3 database server * The PostgreSQL server failed to start. Please check the log output: 2016-01-19 08:50:36 PST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
– Ernie Dunbar
Jan 19 '16 at 16:51
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
It was already chowned to postgresql:postgresql, and doing it again hasn't changed anything. There's nothing in this directory. the file /var/run/postgresql/.s.PGSQL.5432.lock cannot exist, and even if it did and the ownership was correct, it still appears that PostgreSQL actually runs as another user, because it can't write to this directory.
– Ernie Dunbar
Jan 19 '16 at 16:53
add a comment |
I had the exact same problem. I still don't know what caused it, but as a workaround I changed the postgresql pid file directory and unix socket directory (although perhaps the former wasn't necessary). I will call this new directory /pg_workaround
in this answer.
mkdir /pg_workaround
chown postgres:postgres /pg_workaround
chmod 777 /pg_workaround
Then edit /etc/postgresql/<version>/main/postgresql.conf
and modify the following lines:
external_pid_file = '/pg_workaround/<version>-main.pid'
unix_socket_directory = '/pg_workaround'
(Replace /pg_workaround
with the desired location and <version>
with your actual postgres version.)
add a comment |
I had the exact same problem. I still don't know what caused it, but as a workaround I changed the postgresql pid file directory and unix socket directory (although perhaps the former wasn't necessary). I will call this new directory /pg_workaround
in this answer.
mkdir /pg_workaround
chown postgres:postgres /pg_workaround
chmod 777 /pg_workaround
Then edit /etc/postgresql/<version>/main/postgresql.conf
and modify the following lines:
external_pid_file = '/pg_workaround/<version>-main.pid'
unix_socket_directory = '/pg_workaround'
(Replace /pg_workaround
with the desired location and <version>
with your actual postgres version.)
add a comment |
I had the exact same problem. I still don't know what caused it, but as a workaround I changed the postgresql pid file directory and unix socket directory (although perhaps the former wasn't necessary). I will call this new directory /pg_workaround
in this answer.
mkdir /pg_workaround
chown postgres:postgres /pg_workaround
chmod 777 /pg_workaround
Then edit /etc/postgresql/<version>/main/postgresql.conf
and modify the following lines:
external_pid_file = '/pg_workaround/<version>-main.pid'
unix_socket_directory = '/pg_workaround'
(Replace /pg_workaround
with the desired location and <version>
with your actual postgres version.)
I had the exact same problem. I still don't know what caused it, but as a workaround I changed the postgresql pid file directory and unix socket directory (although perhaps the former wasn't necessary). I will call this new directory /pg_workaround
in this answer.
mkdir /pg_workaround
chown postgres:postgres /pg_workaround
chmod 777 /pg_workaround
Then edit /etc/postgresql/<version>/main/postgresql.conf
and modify the following lines:
external_pid_file = '/pg_workaround/<version>-main.pid'
unix_socket_directory = '/pg_workaround'
(Replace /pg_workaround
with the desired location and <version>
with your actual postgres version.)
answered Dec 9 '16 at 23:47
CinnamCinnam
1011
1011
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f721528%2fpostgres-changes-file-permissions-to-its-detriment%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
Notice that the permissions on the folder /var/run/postgresql change from 777 to 775 with a sticky bit on group when I try to start the daemon. The daemon actually changes these permissions to break operation. If I could change it to 777 permanently, at the very least I could find out what user postgresql was actually running as, and fix that, but no, the daemon changes its permissions to break operation instead.
– Ernie Dunbar
Jan 19 '16 at 16:57