Fetching data works with ip address but not with localhost

Hi guys! Can someone explain, when fetching data from strapi why it works with http://127.0.0.1:1337 and with http://localhost:1337 it does not work?
On local host it returns:
connect ECONNREFUSED ::1:1337
I am using next.js latest version and strapi latest version.
Thank you!

This depends on your OS it also is quite a simple google search :slight_smile:

Hi Eventyret!
Thank you for the article. :slight_smile:
Maybe a better question is, why on strapi docs is everywhere localhost instead ip, and why strapi uses it like that?
My OS is Windows 11.
Regards

Because localhost is what is most documentation is using, the IP is different they could have said X.x.x.x but then that would have to be changed to. Most people just copy it instead of read it.

That makes sense. Sorry for bothering you but I want to clear things in my head :smiley:
If I did not google that I must enter 127.0.0.1 how could I know that? Or I must know that the localhost default IP is 127.0.0.1 ?
Should that need to be checked somehow?
Thnx! :slight_smile:

I guess it’s “common” knowledge :blush:
Nothing to apologize for.

You learn by asking :sun_with_face: but it’s part of computer network basics mostly about up addresses etc

1 Like