You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to initialize Lemonsquezy instance according to the official SDK example but I am getting a fetch failed error as below
Error: Lemon Squeezy API error: TypeError: fetch failed
All the env variables are working and I can console print them for surety. Also, the api key is also valid and working in postman.
Below is my code. I am using SDK version ^3.2.0 but I also tried the latest version with the same issue.
import { lemonSqueezySetup } from "@lemonsqueezy/lemonsqueezy.js";
export function configureLemonSqueezy() {
const requiredVariables = [
"LEMONSQUEEZY_API_SECRET_KEY",
"LEMONSQUEEZY_STORE_ID",
"LEMONSQUEEZY_WEBHOOK_SECRET",
];
const missingVariables = requiredVariables.filter(
(varName) => !process.env[varName]
);
if (missingVariables.length > 0) {
throw new Error(
`Missing required LEMONSQUEEZY env variables: ${missingVariables.join(
", "
)}. Please, set them in your .env file.`
);
}
lemonSqueezySetup({
apiKey: process.env.LEMONSQUEEZY_API_SECRET_KEY!,
onError: (error) => {
console.error(error);
throw new Error(`Lemon Squeezy API error: ${error}`);
},
});
}
Scratching my head for past few hours but couldn't figure this strange error out. I am on Next.js version 14.2.5 app router.
UPDATE: I tried implementing the official API using both fetch() and axios and on both counts, getting the below error.
code: 'ECONNREFUSED',
errors: [
Error: connect ECONNREFUSED 127.0.0.1:443
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 443
},
Error: connect EHOSTUNREACH 2606:4700:10::6816:4ef:443 - Local (:::52846)
at internalConnectMultiple (node:net:1176:40)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -65,
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '2606:4700:10::6816:4ef',
port: 443
},
Error: connect EHOSTUNREACH 2606:4700:10::ac43:9df:443 - Local (:::52847)
at internalConnectMultiple (node:net:1176:40)
at internalConnectMultiple (node:net:1177:5)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -65,
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '2606:4700:10::ac43:9df',
port: 443
},
Error: connect EHOSTUNREACH 2606:4700:10::6816:5ef:443 - Local (:::52848)
at internalConnectMultiple (node:net:1176:40)
at internalConnectMultiple (node:net:1177:5)
at internalConnectMultiple (node:net:1177:5)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -65,
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '2606:4700:10::6816:5ef',
port: 443
}
],
I triple-checked the api key, endpoints and all other variables but I couldn't find one single thing that will cause this. Also, the same nextjs server makes external api requests to openAI and other servers without any issue. So even if it is an environment issue, its isolated to lemonsqueezy.
UPDATE 2: So I isolated the issue down to the fact that I cannot reach api.lemonsqueezy.com from my machine. I tried CURL, python and node and even tried GET request in browser to supported endpoints but everywhere I am getting connection refused error. My IP isn't blocked because I tried curl from my wife's laptop on the same network and it can access the api. Stranger Things continues
UPDATE 3: For some reason, api.lemonsqueezy.com was set to localhost in my /etc/hosts file on my Macbook (weird) and that was routing the network request to localhost by resolving DNS to localhost. Remove it and all is good now.
The text was updated successfully, but these errors were encountered:
I am trying to initialize Lemonsquezy instance according to the official SDK example but I am getting a fetch failed error as below
Error: Lemon Squeezy API error: TypeError: fetch failed
All the env variables are working and I can console print them for surety. Also, the api key is also valid and working in postman.
Below is my code. I am using SDK version ^3.2.0 but I also tried the latest version with the same issue.
Scratching my head for past few hours but couldn't figure this strange error out. I am on Next.js version 14.2.5 app router.
UPDATE: I tried implementing the official API using both fetch() and axios and on both counts, getting the below error.
I triple-checked the api key, endpoints and all other variables but I couldn't find one single thing that will cause this. Also, the same nextjs server makes external api requests to openAI and other servers without any issue. So even if it is an environment issue, its isolated to lemonsqueezy.
UPDATE 2: So I isolated the issue down to the fact that I cannot reach api.lemonsqueezy.com from my machine. I tried CURL, python and node and even tried GET request in browser to supported endpoints but everywhere I am getting connection refused error. My IP isn't blocked because I tried curl from my wife's laptop on the same network and it can access the api. Stranger Things continues
UPDATE 3: For some reason, api.lemonsqueezy.com was set to localhost in my /etc/hosts file on my Macbook (weird) and that was routing the network request to localhost by resolving DNS to localhost. Remove it and all is good now.
The text was updated successfully, but these errors were encountered: