DEV Community

critwitt
critwitt

Posted on

Fixing Errno::EIO: Input/Output Error when Running Sinatra for Ruby

I came across and issue while working on my backend server using Sinatra with Ruby. When I would try to run my server locally on my machine, I would get an error on Sinatra's end saying Errno::EIO, and notifying me that there was an input/output error which was preventing me from fetching data from that endpoint. That error might occur because you're trying to access a port which is already in use. There's a lot of fascinating Computer Science that goes into ports but chances are you're just looking to fix this issue.

In your terminal, you want to kill the port that's currently in use. For this example, I will use port 9292, but you should use whatever port you're trying to access.

In your terminal, type the following:

sudo kill -9 `sudo lsof -t -i:9292`
Enter fullscreen mode Exit fullscreen mode

Make sure to use backticks, not apostrophes or quotes. If you're interested in exactly what you're typing, I'll direct you ExplainShell. If you're uninterested in the specifics just know this this is killing the open terminal.

Now when you try to run your server again, Sinatra will work perfectly. Happy Coding!

Top comments (0)