In this post we will resolve error Early termination of puma worker.
Note - Root cause described below is one of the reason. It is possible that this issue may occur due to another reason.
Few days ago, like every normal day I started dev environment rails server and suddenly server log flooded
with error message -
I did not understand why it happened as I did nothing different. Oh, but there was one thing to note - I had to abruptly shut down mac yesterday EOD. Were these issues related?
Yes, they were!
While shutting down mac, postgres server was also abruptly closed - leading stale postmaster.pid file in the
system. And the other day when I was trying to start rails server, it was unable to connect to postgres server. The
reason was postgres server was unable to start as system had
stale postmaster.pid reference.
How did I found the reason -
So the answer was straight forward - Go and delete postmaster.pid file.
How to do it?
I use postgres desktop application, so these were steps for me -
Open terminal & navigate to Postgres directory. You can find postgres directory by opening postgres app and clicking on server settings option. My path was -
- List all files in the directory and check if postmaster.pid file is present.
- Go ahead and remove postmaster.pid -
That’s it. After this step your postgres server should be running & so rails server will be able to connect to it.
P.S. - If you installed postgres via different method then solution steps would be different for you.