Postman connect ECONNREFUSED 127.0.0.1:8080
Asked Answered
C

6

9

Trying to test an API endpoint and got this error. Could it be my request body? Or is it a network issue? Maybe something I need to change in my proxy settings?

POST http://localhost:8080/v1/collections
Error: connect ECONNREFUSED 127.0.0.1:8080
Proxy
authenticate: false
disabled: false
host: "127.0.0.1"
id: "smth"
match: {…}
port: 8080
tunnel: false
Request Headers
Test: check-headers
x-ads-token-data: {stuff}
x-ads-gateway-secret: test1
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Postman-Token: xxxx
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Casuistry answered 23/9, 2020 at 13:36 Comment(8)
is the server listening to the request?Convolvulus
@rags2riches I'm not really sure, since my work just sent me the postman_collection.json and the environment.json files and told me to test the endpoints of the API, so I imported both and now I'm trying to test. So with that, do you know how I might be able to check if the server is listening? thanks so much!Casuistry
You either need to start the server locally, since your request is going to localhost, or change localhost to the server´s URL or IP.Haustorium
I assume you are the developer who needs to test these endpoints, right? so how do you usually start your server locally?Convolvulus
@ChristianBaumann the server's url is actually set to localhost:8080, so I'll probably have to start it locally.. ok at least I know what I need to do, sorry I'm a new intern so I'll get the hang of itCasuistry
Are you using the correct HTTP method? POST /v1/collections is not the same as GET /v1/collections.Moreen
In my case http instead of https or the other way around made a difference.Workshop
since you are using http profile method you are getting the above error. Listen API for https://localhost:8080/v1/collections . You can change the profile in Visual Studio itself or run this command dotnet run --launch-profile httpsWainwright
C
14

econnrefused means most probably you have not started your server on port 8080.

Take a look at the nodejs documentation here

ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.

Convolvulus answered 23/9, 2020 at 13:45 Comment(2)
I am facing the same error when testing my API on Postman. The server is running successfully as logged in the terminal and my application is connected to my MongoDB database instance. What could be the problem? When I try to connect using MongoDB compass, it works fine but when I use Postman, it doesn't and throws : Error: connect ECONNREFUSED 127.0.0.1:8080Handbarrow
I am having the same issue with eclipse ide. Everything was working fine with postman until I added the spring boot security configuration. All of a sudden, I am getting the connection refused error, but it happens in debug mode only. I can run the application in normal mode, the post/get requests work.Unwelcome
J
4

I am new to doing REST API and was trying to do Post request. I got this error when I was using Postman and c#

POST https://localhost:44310/api/Books
Error: connect ECONNREFUSED 127.0.0.1:44310
Request Headers
Content-Type: application/json
User-Agent: PostmanRuntime/7.28.4
Accept: */*
Host: localhost:44310
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Request Body
{
    "Id": 1,
    "Title": "Harry Potter",
    "Author": "J.K. Rowling",
    "Pages": 500
}

what happened was that the program was not running in visual studio but after executing it, the error did not appear again.

Jonjona answered 23/10, 2021 at 22:45 Comment(0)
N
4

I was also suffering from the same problem. At that point in time, my local server was not published. So I simply ran my backend server on IntelliJ IDEA. Then try to post the request. It works for me.

So, according to my experience, I would like to suggest that, Before posting or getting any request you have to confirm that your local server is running properly.

Nonconformist answered 3/8, 2022 at 15:32 Comment(0)
N
2

Hope my response will be useful. I got the same issue and looks like clearing the breakpoints and setting the same again fixed the issue.

Nikolenikoletta answered 21/2, 2022 at 12:32 Comment(0)
T
0

I stumbled upon the same error while trying to reach endpoints on a tomcat webapplication.

Solution for me was:

  • Edit host adress to https and port 8443
  • server.xml in my tomcat conf directory needed an SSL connector listening on 8443 for my example and also including certificate files in the right directory
  • connector with port 8080 needed a redirectingPort on 8443
Taffy answered 5/9 at 14:54 Comment(0)
I
-1

I had the same problem and solved it by defining the "Edit / run configuration dialog" in IntelliJenter image description here

Iover answered 15/4, 2022 at 9:55 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Desist

© 2022 - 2024 — McMap. All rights reserved.