[Ruby] How to deal with A server is already running… that occurred without disconnecting the rails server at the terminal

1 minute read

When I was messing with the local Visual Studio Code terminal, it was forced to terminate due to a PC malfunction.

After that, when I started the Rails server again,

A server is already running.

Came out.

Normal shutdown when the server is running is OK with “ctrl + C”, but in this case there was no reaction when this command was executed.

There are two workarounds here,

1.Run kill -9 $(lsof -i tcp:3000 -t)

  1. Restart your PC

I chose 1. and I was able to make the server connection blank for the time being.

Supplement (problem with inability to access localhost:3000)

When I connected the server again thinking that “Ah for the time being,”

yuichi kanban %rails s => Booting Puma => Rails application starting in development => Run rails server -h for more startup options Puma starting in single mode…

  • Version 3.12.6 (ruby 2.6.6-p146), codename: Llamas in Pajamas
  • Min threads: 5, max threads: 5
  • Environment: development
  • Listening on tcp://localhost:3000 Use Ctrl-C to stop

However, it did not load even if I searched localhost:3000 in the browser.

In these cases, it’s similar to the workaround above, but once I closed Visual Studio Code and woken up again, Yay! You’re on Rails! was safely displayed.

If it gets stuck, restarting it will probably solve the problem, so please try it. (suitable)