Error: connect ECONNREFUSED 127.0.0.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 80,
config: {
url: 'http://localhost:8080',
method: 'get',
headers: {
Accept: 'text/html, application/json, text/plain, */*',
'User-Agent': 'axios/0.21.1',
host: 'localhost:8080'
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
httpsAgent: Agent {
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object]
validateStatus: [Function: validateStatus],
data: undefined
request: Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object]
writable: true,
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
_eventsCount: 2,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'http:',
path: 'http://localhost:8080/',
method: 'GET',
headers: [Object],
agent: undefined,
agents: [Object],
auth: undefined,
hostname: null,
port: null,
host: null,
beforeRedirect: [Function: beforeRedirect],
nativeProtocols: [Object],
pathname: 'http://localhost:8080/'
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Socket],
connection: [Socket],
_header: 'GET http://localhost:8080/ HTTP/1.1\r\n' +
'Accept: text/html, application/json, text/plain, */*\r\n' +
'User-Agent: axios/0.21.1\r\n' +
'host: localhost:8080\r\n' +
'Connection: close\r\n' +
'\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: 'GET',
path: 'http://localhost:8080/',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable: [Circular],
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]: [Object: null prototype]
_currentUrl: 'http:http://localhost:8080/'
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
No docker or any proxy involved.
On Mon., Jul. 12, 2021, 3:52 a.m. Danil27, ***@***.***> wrote:
Are you using docker?
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<
#3821 (comment)>, or
unsubscribe
<
https://github.com/notifications/unsubscribe-auth/ABZCWGM7SWV422QOS36AUWTTXKNLVANCNFSM46A4WKEQ>
marcelozarate, RaviPabari, NathanQuellec, ajeetjha2711, MNabeelHassan, AndreZila01, sGambolati, Alexis-Dernoncourt, bostjanb, and benbrewerrazorfish reacted with thumbs up emoji
dragosrotaru, OTTTO, GabiArrieta, Art-auto, Muha-tsokotukha, pouyan-sh, LogansUA, jamesnicolas, bgdnvk, volfadar, and 3 more reacted with thumbs down emoji
RaviPabari, NathanQuellec, mdammar786, jameschris854, vicenttcarvalho, AndreZila01, bostjanb, and MinhVoyager reacted with heart emoji
All reactions
I got the error while following the this link.
Error: connect ECONNREFUSED 127.0.0.1:80 TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
https://auth0.com/docs/architecture-scenarios/spa-api/api-implementation-nodejs
Any idea on this?
I too have the very same issue as reported here.
I "think" i know "kindof" why.
Like the other examples here, i was using a http://localhost:8080
or structured similarly URL.
This gave me a connection refused which is actually giving a hint:
Error: connect ECONNREFUSED ::1:8080
While i did not in any place or location specify IPv6, the error does indicate an IPv6 call, not v4!
In my case changing localhost
to 127.0.0.1
did "fix" it.
Debugging this further with ping localhost
showed me that magical ::1
too. It was an ipv6 ping.
I haven't quite figured it out yet but i'm guessing there is an error in the users /etc/hosts
file where localhost is missing. I'll report back if i know more about that.
Edit. Don't know... It is something with the hosts and something with ipv6 but i don't know what triggers this. Using the ip instead does work but feels wrong.
boyandimitrov, Kearnol, ceosss, damianmr, Bryan050, Yokai1000, ThienTranDuy, khoyadev, nozomi-iida, devupmaster, and 38 more reacted with thumbs up emoji
rogeriocassares, StephenBurgos, and Motoxpro reacted with hooray emoji
rogeriocassares, StephenBurgos, tadayosi, lianghua1987, Motoxpro, jaalorsa517, and ArturCRS reacted with heart emoji
All reactions
If you're using environment variables, check the route.
In my case, I mistakenly commented my: //require('dotenv').config();
My route was underfined.
process.env.MY_ROUTE
Lightinway, lycpan233, dante01yoon, abdoutech19, GhanbarT, j-oliver, sebysebyseby, Yiuuuuu, felipebsouza, is-andrade, and 4 more reacted with thumbs up emoji
dragosrotaru reacted with thumbs down emoji
abdoutech19, felipebsouza, and Sotatek-TuanLe2 reacted with hooray emoji
abdoutech19, mitchellcarroll, felipebsouza, and Sotatek-TuanLe2 reacted with heart emoji
All reactions
Axios' RequestConfig has baseUrl
and url
.
For me, I was setting my server's url using url
instead of baseUrl
in axios.create()
which was what was causing the error for me.
Making sure I used baseUrl
when creating my AxiosInstance
fixed the problem.
Axios must adhere to the specification of a valid URL, that's just common sense. The user of an interface should not have to care about the implementation. http://localhost:8080/
is a fully valid URL according to the RFC spec, and according to the Axios documentation.
As @aleyeeey pointed out, _currentUrl: 'http:http://localhost:8080/'
is a good hint that Axios is doing something behind the scenes that it should not be doing.
The issue, probably lies in "proxy:undefined". The Axios documentation says the following:
Use false
to disable proxies, ignoring environment variables.
Therefore, I am going to close this issue on account that the request I have included is actually NOT adhering to the documentation. However, it is still suspect that defining proxy:undefined
would lead to such an error, as the code should not have such a high specificity: null, false or undefined should be acceptable values, semantically speaking there is no reason NOT to accept undefined
.
It might not be related to proxy at all.
Hi 👋
Please could you retry with the latest version and open a new issue should this error still be relevant?
Thanks
I too have the very same issue as reported here. I "think" i know "kindof" why.
Like the other examples here, i was using a http://localhost:8080
or structured similarly URL. This gave me a connection refused which is actually giving a hint:
Error: connect ECONNREFUSED ::1:8080
While i did not in any place or location specify IPv6, the error does indicate an IPv6 call, not v4! In my case changing localhost
to 127.0.0.1
did "fix" it.
Debugging this further with ping localhost
showed me that magical ::1
too. It was an ipv6 ping. I haven't quite figured it out yet but i'm guessing there is an error in the users /etc/hosts
file where localhost is missing. I'll report back if i know more about that.
Edit. Don't know... It is something with the hosts and something with ipv6 but i don't know what triggers this. Using the ip instead does work but feels wrong.
i had exactly same issue, I checked my '/etc/hosts' and saw '::1 localhost', removing that line fixed my issue
edit: as markg85 suggests, do not delete "::1 localhost". Thanks markg85 for pointing out
i had exactly same issue, I checked my '/etc/hosts' and saw '::1 localhost', removing that line fixed my issue
Don't do or even recommend that!
It's your localhost lookup. Your pc in IPv6 now doesn't know it's localhost anymore. Which is, frankly, probably fine as not much - if any - is using it. Still, it's very bad practice to delete that line.
Server Error
Error: connect ECONNREFUSED 127.0.0.1:1337
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
error: connect ECONNREFUSED 127.0.0.1 (1337)
(Error: connect ECONNREFUSED
127.0.0.1 (1337)
TCPConnectWrap.afterConnect [as oncomplete]
node:net (1157:16)****
ConnorGDevelopment, KoljaL, thanarack, usimsatuna, znalexandr, miroslawlis, brickfungus, spmobileprods, rohanpatelg, jackton1, and 8 more reacted with thumbs up emoji
znalexandr, rohanpatelg, and jackton1 reacted with hooray emoji
rohanpatelg and jackton1 reacted with heart emoji
rohanpatelg, jackton1, and rogeriocassares reacted with rocket emoji
All reactions
http://localhost:8080 => http://127.0.0.1:8080
I had a similar issue with the same solution on Strapi.
Don't know why it works, but it works...
It looks like the newer node version and axios resulted in the use of
IPv6 addresses and the dev server does not seem to respond to those.
See also: axios/axios#3821
It looks like the newer node version and axios resulted in the use of
IPv6 addresses and the dev server does not seem to respond to those.
See also: axios/axios#3821
For anyone wondering why this is happening, Node.js switched the lookup order of DNS resolution from v17 onwards.
You can switch back to the old behaviour (putting IPv4 first) with:
import { setDefaultResultOrder } from "dns";
setDefaultResultOrder("ipv4first");
Otherwise, yes explicitly using IPv4 127.0.0.1
instead of localhost
(which can get resolved to either IPv4 loopback 127.0.0.1
or IPv6 loopback ::1
) should work.
atulmy, megafinz, Aeolun, derekperriero, dkr88, yanshiyason, KyleBrown-804, R4tonBaveur, ikoif, nawaphonOHM, and 8 more reacted with thumbs up emoji
KyleBrown-804 and bilalisler reacted with hooray emoji
KyleBrown-804, rights-uchida, and irondsd reacted with heart emoji
All reactions
By default, Axios redirects us to 127.0.0.1:80 if it doesn't find the requested URL or HTTP method(GET/POST/PUT)
check your URL if are also using Axios.
I too have the very same issue as reported here. I "think" i know "kindof" why.
Like the other examples here, i was using a http://localhost:8080
or structured similarly URL. This gave me a connection refused which is actually giving a hint:
Error: connect ECONNREFUSED ::1:8080
While i did not in any place or location specify IPv6, the error does indicate an IPv6 call, not v4! In my case changing localhost
to 127.0.0.1
did "fix" it.
Debugging this further with ping localhost
showed me that magical ::1
too. It was an ipv6 ping. I haven't quite figured it out yet but i'm guessing there is an error in the users /etc/hosts
file where localhost is missing. I'll report back if i know more about that.
Edit. Don't know... It is something with the hosts and something with ipv6 but i don't know what triggers this. Using the ip instead does work but feels wrong.
This worked for me. An absolute gem.
Connection to Rusk Failed, some operations won't be available: error sending request for url (http://127.0.0.1:8080/): error trying to connect: tcp connect error: Connection refused (os error 111)
this happened while i was using putty