Search code examples
rubyhttprequestporttcpmon

What port does Ruby's net/http use?


I am using Ruby's net/http library to send RESTful requests to my dev server. I've been having issues correctly parsing the data I'm sending in the request and so I'm not looking into ways to inspect the request I'm sending out through Ruby.

On another question I posted here, asking how JSON data was sent in an http request, I received a comment saying that I could possibly inspect the request by using TCPMon. In order to use TCPMon though to check the request, I need to know which port to look for the request on.

And that brings me here. What port does Ruby (and net/http) use to send out HTTP requests?


Solution

  • Unless otherwise specified, it will make requests to port 80 for http requests, and port 443 for https requests (the standard http/https ports).

    However, you'll set up TCPMon to listen to requests on a certain port, and then forward them on to their destination. So if TCPMon is listening on 8080, you'll make the requests to port 8080.