IPAddress from React book component only works w/ "on your network"

so from the React book, the <IPAddress /> and <IPAddressContainer /> app only shows the IP address on the screen when I click where the mouse is in this pic:

yet the picture in the book has localhost:3000 in the address bar. Did I do something wrong, or did the author forget to say something about this? I used npm start to run the thing.

There may be nothing wrong, for the HTTP Server adjusts what port it works on depending on a variety of system parameters. When you do navigate to localhost, what do you see?


when I navigate to the local host, all I get are the elipses that were put in in the constructor instead of an IP address

Does your browser’s Developer Tools Console display any errors?

yes, in Chrome, I get this:

I’m having the same issue too, 429 error means the server has reached its limit or something…

That seems really odd. The request should only be made once every time you refresh the browser (or have the hot reload functionality reload for you). Does the error keep happening even if you try again after a few minutes?

Still happens. Here is the detail of the error message.

Does the example at this location work? https://www.kirupa.com/react/examples/ipaddress.htm

I’m trying to figure out what ipinfo is using to track the rate limit.

Yes, the example still works.

I have no idea what is going on here! Does anybody else have any ideas? :frowning:

I have the same issue too. The website’s example works, but not my localhost.

I am having the same problem, but just from localhost. I happen to have tried this in a virtual machine and checked from the host system as well using the IP my VM has in the shared network, and with that the code works. My guess is that somehow the sender of the request to ipinfo.io gets to be “localhost” if you use the app as probably most people do when just trying out, and “localhost” most probably has way more than 1000 requests/month to them (see https://ipinfo.io/pricing) and therefor we get blocked.

1 Like

Yep! That’s pretty much the only explanation that makes sense :stuck_out_tongue:

Hi everyone - I just posted a workaround here: Chapter 14 too many requests error

In short, you can sign-up for a free account at ipinfo.io and use the token as part of making the request. The other option is to just use my free token instead: https://ipinfo.io/json?token=2277ce4bac0347

  componentDidMount() {
    xhr = new XMLHttpRequest();
    xhr.open("GET", "ipinfo.io/json?token=2277ce4bac0347", true);
    xhr.addEventListener("readystatechange", this.processRequest, false);

The only risk with using my token is that there is a slight chance that many of you might be using it daily and that the request limit might get reached :slight_smile: