My local Postgres server is configured to start when the computer starts. I just changed postgresql.conf file and had to restart the server. I did:

pg_ctl restart

from the command line BUT that started the server on the next command prompt:

pg_ctl: old server process (PID: 2968) seems to be gone
starting server anyway
server starting

D:\>2016-10-12 16:24:48 EDT LOG:  redirecting log output to logging collector proces
2016-10-12 16:24:48 EDT HINT:  Future log output will appear in directory "pg_log".

If I ctrl-c out of it or close the command window, that closes the server. How can I use pg_ctl to (re)start the server in the background, emulating how it works by default (as a Windows service)?

  • 4
    If Postgres is registered as a Windows service you should use net stop and net start to stop and start it. Not pg_ctl Oct 12, 2016 at 20:41
  • what is the name of the service ?
    – amphibient
    Oct 12, 2016 at 20:47
  • 2
    You should know that, you installed it. You can check in with services.msc typically it's postgresql-9.5 (or whatever version you are using) Oct 12, 2016 at 20:53
  • 1
    yeah, i got it by going into windows services (postgresql-x64-9.6). i'm just not that familiar with windows...
    – amphibient
    Oct 12, 2016 at 20:56

1 Answer 1


As it turns out, it was running in the console because I didn't tell it where to stream the log. The following sent the process in the background:

pg_ctl restart -l %PGDATA%\server.log
  • 1
    Please don't ask new questions in answers. If your answer is the solution to your original question, please accept it when the system permits that, but as for your new question, please remove it from the answer and submit it as a proper new question. You can include a link to this one into it if the two are related and you believe that would help to understand the new question better. Thank you.
    – Andriy M
    Oct 12, 2016 at 21:59
  • Note: even when I specify a log file, it still shuts down the server when I subsequently hit ctrl-c on the command line.
    – Erhannis
    Sep 1, 2017 at 17:58
  • Also, there was a whole thread on what changes to make with respect to this issue; I can't tell what the consensus was, whether they ever fixed it. postgrespro.com/list/thread-id/1835410
    – Erhannis
    Sep 1, 2017 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.