localhost times out after accidental ctrl + Z
Asked Answered
M

2

6

I am currently creating a website on Codeanywhere that communicates with a back-end API/server. I ran my server.js node script with my ports on 8080 (front-end) and 8081 (server). However, I normally close the connection with Ctrl + C but I accidentally used Ctrl + Z to close the server down and since then I cannot run it again. Since I accidentally used Ctrl + Z and closed the tab on codeanywhere before doing anything else out of fear of damage my local host on codeanywhere when I run the script will not connect but instead take too long and time out. I am desperate for a solution as this is for a university module.

Mainsail answered 25/11, 2017 at 22:25 Comment(0)
C
5

Pressing Ctrl+z does not stop your application, it sends it to the background. I wouldn't describe it as being in a running state but resources (such as the port) it was previously using remains bound to it.

Your application was timing out because you were trying to start another instance that shared the same resource (port) as the paused one.

To fix, type fg in your terminal and it should restore your application.

I know this question was asked a long time ago but who knows who this answer might help.

Cupcake answered 4/10, 2020 at 21:33 Comment(0)
T
1

You need to kill the node process. By doing Ctrl Z you are just suspending it, without freeing it's locked resources (like the TCP port your are listening to).

If no other Node.js processes are running and killall is available you could easily do killall node and then restart the server. Else use any tool to kill the node process.

Talky answered 25/11, 2017 at 22:46 Comment(3)
how would I use the killall command? would it work even if I pressed CTRL + Z then closed the tab and reopened codeanywhere? I can run the server node script just fine but as I mentioned, when I attempt to run it after the incident, it just hangs and I get a connection timed out error even though before it worked fine.Mainsail
Yes it should if the terminal is on the same container. In the worst case you can restart your container.Talky
I just restarted the container but same situation, it tries to connect then gives an error. It also doesn't appear to be running because using the killall isn't workingMainsail

© 2022 - 2024 — McMap. All rights reserved.