EventMachine: "` `start_tcp_server": no acceptor (uses port or requires root privileges) "

When I try to start the server with EventMachine::run , I get an error all the time saying that the port is in use. It started since I started the server in the background using the nohup command.

I am sure that I killed the process that I started.

  • I found a ruby โ€‹โ€‹process with ps and killed it. It is no longer displayed.
  • I also ran lsof -i :8081 (8081 is the port on which I ran it) and nothing is displayed.
  • Finally, I changed the port several times in the ruby โ€‹โ€‹program to obscure the ports, and still get an error!

I also, although this may be due to the fact that I am not a root user, so I tried it as root to no avail.

I also restarted the server.

Please let me know if there is anything else that I can try.

Note: this is on debian.

+6
source share
5 answers

I finally realized that it was an IP address that I linked to what was wrong!

So this is a very erroneous error message, and if you get it, check the IP address as well.

+12
source

This happens when you did not stop your server correctly, for example, when it was suspended using Ctrl + Z or twice starting the server.

If Ctrl + Z is stopped, this works for me:

Get running process using

 $ ps ax | grep rails 18192 pts/28 Sl+ 0:05 /home/admin/.rvm/rubies/ruby-2.1.2/bin/ruby bin/rails c 20496 pts/23 Tl 0:08 /home/admin/.rvm/rubies/ruby-2.1.2/bin/ruby bin/rails s 20919 pts/23 S+ 0:00 grep --color=auto rails 

And then start the process where the rails server is running:

 $ kill 20496 

If it does not close after a few seconds, you can try to "force close" with -9 (but this will prevent any Rails cleanup):

 $ kill -9 20496 

Now you can start the server again:

 $ rails s 
+12
source

There was the same problem.

Ran lsof -i :3000 (3000 is the port on which I ran it).

I found out that the port was used by ruby. I killed the process using kill -9 *pid* .

When I ran lsof -i :3000 again, nothing appeared.

Then I ran rails s and now everything is working fine.

+9
source

Working on a free port solves the problem:

 rails s -p 3001 

or

 ruby script/rails server webrick -e production -p 3001 

or

 ruby script/rails server thin -e production -p 3001 
0
source

In my case, these were problems connecting to the Internet.

0
source

Source: https://habr.com/ru/post/980735/


All Articles