wont let me run rails s because there is another server running but i don't know how to access that server - ruby-on-rails

How do I close the old server even though I can't see its terminal anymore so I can access my project?
I tried exiting out of the program then exiting back in but nothing would work.
keeps bringing up this error:
A server is already running. Check C:/Users/Nathan/Documents/Aptana Studio 3 Workspace/Nathans First project/tmp/pids/server.pid.
Exiting

Use netstat to find the process id running on the port the server has bound to. Then kill that process.
run cmd.exe as administrator.
To list process
C:\> netstat -a -b
Find the process id that is bound to the port your server runs on
C:\> Taskkill /PID <the process id (pid) of the server> /F

can you visit your app from the url 127.0.0.1:3000, 3000 is the port your app suppose to be running.
Case 1. if you can visit at the location, then use the activity monitor or something like that , find the ruby process and kill it.
Case 2. if you can not visit, then just delete the file C:/Users/Nathan/Documents/Aptana Studio 3 Workspace/Nathans First project/tmp/pids/server.pid will be fixed this problem. It is cause by a abnormal server exist like you shutdown your computer without shutdown the server normally.

Check you tmp/pids/server.pid file under your app which wil have the process id of other instance of rails server currently running. First kill that process using kill -9 process_id in your linux terminal. Check how to kill a process for your particular version

Delete the server.pid file in the C:/Users/Nathan/Documents/Aptana Studio 3 Workspace/Nathans First project/tmp/pids/ directory and restart the server.
Make sure you close the command prompt window and open it again before restarting the server.
Hope this helps!

Related

DispatchSource.makeReadSource is holding onto socket after app is killed by Xcode [duplicate]

I am attempting to bind a socket to a port below:
if( bind(socket_desc,(struct sockaddr *) &server, sizeof(server)) < 0)
{
perror("bind failed. Error");
return 1;
}
puts("bind done");
But it gives:
$ ./serve
Socket created
bind failed. Error: Address already in use
Why does this error occur?
Everyone is correct. However, if you're also busy testing your code your own application might still "own" the socket if it starts and stops relatively quickly. Try SO_REUSEADDR as a socket option:
What exactly does SO_REUSEADDR do?
This socket option tells the kernel that even if this port is busy (in
the TIME_WAIT state), go ahead and reuse it anyway. If it is busy,
but with another state, you will still get an address already in use
error. It is useful if your server has been shut down, and then
restarted right away while sockets are still active on its port. You
should be aware that if any unexpected data comes in, it may confuse
your server, but while this is possible, it is not likely.
It has been pointed out that "A socket is a 5 tuple (proto, local
addr, local port, remote addr, remote port). SO_REUSEADDR just says
that you can reuse local addresses. The 5 tuple still must be
unique!" by Michael Hunter (mphunter#qnx.com). This is true, and this
is why it is very unlikely that unexpected data will ever be seen by
your server. The danger is that such a 5 tuple is still floating
around on the net, and while it is bouncing around, a new connection
from the same client, on the same system, happens to get the same
remote port. This is explained by Richard Stevens in ``2.7 Please
explain the TIME_WAIT state.''.
You have a process that is already using that port. netstat -tulpn will enable one to find the process ID of that is using a particular port.
Address already in use means that the port you are trying to allocate for your current execution is already occupied/allocated to some other process.
If you are a developer and if you are working on an application which require lots of testing, you might have an instance of your same application running in background (may be you forgot to stop it properly)
So if you encounter this error, just see which application/process is using the port.
In linux try using netstat -tulpn. This command will list down a process list with all running processes.
Check if an application is using your port. If that application or process is another important one then you might want to use another port which is not used by any process/application.
Anyway you can stop the process which uses your port and let your application take it.
If you are in linux environment try,
Use netstat -tulpn to display the processes
kill <pid> This will terminate the process
If you are using windows,
Use netstat -a -o -n to check for the port usages
Use taskkill /F /PID <pid> to kill that process
The error usually means that the port you are trying to open is being already used by another application. Try using netstat to see which ports are open and then use an available port.
Also check if you are binding to the right ip address (I am assuming it would be localhost)
if address is already in use can you just want to kill whoso ever process is using the port, you can use
lsof -ti:PortNumberGoesHere | xargs kill -9
source and inspiration this.
PS: Could not use netstat because it not installed already.
As mentioned above the port is in use already.
This could be due to several reasons
some other application is already using it.
The port is in close_wait state when your program is waiting for the other end to close the program.refer (https://unix.stackexchange.com/questions/10106/orphaned-connections-in-close-wait-state).
The program might be in time_wait state. you can wait or use socket option SO_REUSEADDR as mentioned in another post.
Do netstat -a | grep <portno> to check the port state.
It also happens when you have not give enough permissions(read and write) to your sock file!
Just add expected permission to your sock contained folder and your sock file:
chmod ug+rw /path/to/your/
chmod ug+rw /path/to/your/file.sock
Then have fun!
I was also facing that problem, but I resolved it.
Make sure that both the programs for client-side and server-side are on different projects in your IDE, in my case NetBeans. Then assuming you're using localhost, I recommend you to implement both the programs as two different projects.
To terminate all node processes:
killall -9 node
First of check which port are listening,
netstat -tlpn
then select available port to conect,
sudo netstat -tlpn | grep ':port'
Fix it into also to your server and clients interfaces. Go Barrier tab -> change settings, -> port value type -> save/ok
Check both clients and server have similar port values
Then Reload.
Now it should be ok.
Check for running process pid:
pidof <process-name>
Kill processes:
sudo kill -9 process_id_1 process_id_2 process_id_3

neo4j server is not restarting or stopping

I am getting the following errors and I dont know how to restart the server .I tried multiple times but I get the same error all the time.How can I stop and restart the server.I really appreciate any help.
./bin/neo4j start
displays:
/usr/local/neo4j/data/log/console.log: Permission denied
process [11825]... waiting for server to be ready.. Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
sudo ./bin/neo4j start
displays:
Another server-process is running with [ST=ESTABLISHED], cannot start a new one. Exiting.
The exception you get is because another server is running.
Also, there is another exception, you don't have write access in the folder for the logs.
Check if http://localhost:7474 is displaying the neo4j web browser.
If yes, locate the location of the running database :
Then go to the location and stop the db, eg based on the image :
cd /Users/cw/_graphs/tests
./bin/neo4j stop
If it is not working, try to kill the process :
sudo htop
kill -9 10522
And try to run your new database. And make sure you have the right permissions for the stores and logs.

neo4j community edition 2.1.6 server process running even after server stop command executed

I know at least a few of us had this issue come up...I am issuing the command to start the server and yet it tells me that a server process is still running at 17922...I then try the following:
./bin/neo4j status
And it tells me: "Neo4j Server is not running"
Then I issue the command to start a new server: ./bin/neo4j start
and I get the following:
Another server-process is running with [17922], cannot start a new one. Exiting.
Not looking to run multiple Neo4J servers, so I'd like to stop whatever is running in the background.
Seems the process is not nicely responding for whatever reason. You might want to inspect the log files (data/log/* and data/graph.db/messages.log) to get more insight.
To terminate the process use kill 17922. If that does not help, kill -9 17922.

Rails server will not stop and even if it is running it is not working

I am new to Ruby on Rails, but I managed to install it using the RailsInstaller and I am using Aptana Studio 3 as a text editor. I am on a Windows 7 x64.
Last week I managed to create a simple Hello world project, and it worked as it should when starting and stopping the rails server. To start the server I used the command rails server and to stop it I used CTRL+C.
Somehow, this week, when I'm trying to start the server it says "A server is already running". But, when I go to the correct page in a web browser it doesn't work. I get the error "Google Chrome could not connect to localhost:3010". So, this makes it seem like the server is not working, even though it supposedly is running.
So, I then try to stop the server from running, but CTRL+C doesn't seem to do anything. It doesn't give any kind of message at all when I input that, it just skips to a new line in the terminal window.
the standard port is 3000.
You can kill the server in the task manager and start it from new..
There is probably a rails process still running but bugged out/crashed. Try looking at the processes in the windows task manager to for a rails process, and cancel it. Additionally you can start a rails process on a different port with rails server -p PORT

how to restart a grails web application

how can I restart a grails application other than shutting it down by doing ctrl z and running it again.
when I do it that way it says
Error Server failed to start for port 8080: Address already in use
CTRL-Z doesn't shut down an application, sends a SIGTSTP signal to the process to suspend it... Suspended processes still have connections to their resources (ports, files, etc), so you cannot run another instance of grails on the same port whilst one is suspended.
To bring it back to the foreground, you can enter fg in the same shell (or if you want it to run in the background, you can use bg)
To shut it down, you need CTRL-C (or you can kill it as nickdos says in the comments)
To cleanly shut down a run-app or run-war, create an empty file named .kill-run-app in the top-level directory of your grails application (i.e. alongside grails-app, src, etc.). Grails will automatically delete this file once the application has been stopped, so don't be surprised when it disappears shortly after you created it.
Shutdown should not require process hacking and doesn't require a 'could ruin everything' disclaimer :)
Just run:
grails stop-app
If that still doesn't work:
lsof -i :8080 or ps aux | grep grails
Will show the process id, then first try killing it nicely:
kill 12345 (where 12345 is the processId)
Of if it really doesn't want to play nicely, then HAMMER it with:
kill -9 12345 (where 12345 is the processId)
Works every time (DISCLAIMER: Could ruin everything)

Resources