I'm trying to make a request to my local API from the Swagger documentation, but it always gives this error when I make the request
-
What's the error message on the Console tab in the browser dev tools? – Helen Sep 13 '22 at 17:54
-
Just got the same problem. Seems my network driver was down or something. Socket couldn't open. After reboot everything was back. No clue about the root cause, I'm interested if you find something or if a reboot helped you too – Cyril ANDRE Sep 16 '22 at 13:39
-
Consegui resolver o problema, na verdade o problema estava na própria API que eu estava tentando acessar. – Iago Alexandre Sep 19 '22 at 17:39
-
@IagoAlexandre What was the problem? I'm still having this same problem – natielle Sep 30 '22 at 22:34
-
I just had this problem. After a few hours trying to figure out what was causing it I found that it was related to a Cookie I was adding to the response. The problem was that the Cookie was too big but there was no error indicating the actual problem. – Juan Portillo May 17 '23 at 11:30
6 Answers
First check that your address is not blocked by cors, for dev tests you can use Access-Control-Allow-Origin:*
.
If it doesn't work for you, check that you are not using an extension on your browser, such as those that block ads. You delete it from your browser, restart it and test again, it will work.

- 98
- 1
- 6

- 331
- 4
- 18
In my case, I was accessing the web application via 127.0.0.1:3000, once I changed it to localhost:3000, it worked, hope that helps

- 444
- 4
- 11
after Starting IIS Express ... web API register on 2 URL, one port is for http, and the other one is for https. when you call http port you see this error:Failed to fetch. Possible Reasons: CORS Network Failure URL scheme must be "http" or "https" for CORS request. change the port to https Port.

- 313
- 1
- 9
In swagger.json
I accidently sat my host port to http://localhost:3000
and my server was running on port :5000
.
Once I updated the host port to match the one I'm using to send my requests using swagger ui, the problem's gone.

- 124
- 2
- 4
Choose the "http" option at the run icon on the top of the screen:

- 7,102
- 69
- 48
- 77

- 1
- 1
-
this suggestion could be useful but it is not totally clear what you are setting the http option for. It's helpful to explain external links – user7247147 Mar 19 '23 at 05:39
A bit of an edge-case situation, but if you are running from a container, ensure you are doing your port forwarding correctly.
As one of the answers above states, your application should be running on localhost:<port_of_choice>
instead of 127.0.0.1:<port_of_choice>

- 1,356
- 12
- 20