Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ECONNREFUSED - /wp-json/wp/v2/types #16

Open
simduchaine opened this issue Jul 15, 2019 · 9 comments
Open

Error: ECONNREFUSED - /wp-json/wp/v2/types #16

simduchaine opened this issue Jul 15, 2019 · 9 comments

Comments

@simduchaine
Copy link

When I'm running "gridsome explore" or "gridsome develop" commands, I get this error:

$ gridsome explore
Gridsome v0.6.6

Initializing plugins...
Initialize - 1.81s
Loading data from
Error: ECONNREFUSED - /wp-json/wp/v2/types
    at WordPressSource.fetch (B:\Projets\Dev\Websites\travel-blog-gridsome\node_modules\@gridsome\source-wordpress\index.js:168:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I tried the endpoint /wp-json/wp/v2/types in my browser and in Postman and I was able to access the endpoint without any problem.

@CSchloegel
Copy link

I'm having this same issue

@Alligatore3
Copy link

Hi @simduchaine
Can you please provide your gridsome.config ?

I had the same error but I was giving the wrong baseUrl for my local Wordpress environment.

@simduchaine
Copy link
Author

@Alligatore3 Here's my gridsome.config.js:

module.exports = {
  siteName: "Gridsome",
  siteDescription: "A WordPress starter for Gridsome",
  plugins: [
    {
      use: "@gridsome/source-wordpress",
      options: {
        baseUrl: process.env.WORDPRESS_URL, // required
        apiBase: "wp-json",
        typeName: "WordPress",
        perPage: 10,
        concurrent: 0,
        routes: {
          post: "/:year/:month/:day/:slug",
          post_tag: "/tag/:slug"
        }
      }
    }
  ]
};

And here's my ENV variable:
[template.environment] WORDPRESS_URL = "https://voyage.simonduchaine.com"

Note that I'm trying to fetch a live prod website not a local wordpress env.

@Alligatore3
Copy link

Alligatore3 commented Jul 31, 2019

@simduchaine
I'm not an expert with node env but I'm pretty sure that if you put your_path directly inside gridsome.config.js it works.

I tried with my remote env, I put my URL like this:
options: { baseUrl: 'https://voyage.simonduchaine.com', // required

Actually I got another error 😅 but at least not this one.

@simduchaine
Copy link
Author

@Alligatore3 tried your suggestion, didn't get the ERCONNREFUSED but still, the issue is almost the same as now it's Graphql throwing a error 500 (try the gridsome explore command and you'll see).

@StephenGilboy
Copy link

StephenGilboy commented Dec 17, 2019

I know this is quite a few months old but for someone else who might run into this issue I was able to solve it by adding a .env file and setting the WORDPRESS_URL= there.

@dosstx
Copy link

dosstx commented Apr 24, 2020

I know this is quite a few months old but for someone else who might run into this issue I was able to solve it by adding a .env file and setting the WORDPRESS_URL= there.

What is the exact file name for the .env file you added? Is it just .env.json in root?

@StephenGilboy
Copy link

StephenGilboy commented Apr 24, 2020

I know this is quite a few months old but for someone else who might run into this issue I was able to solve it by adding a .env file and setting the WORDPRESS_URL= there.

What is the exact file name for the .env file you added? Is it just .env.json in root?

The exact file name is .env it is called a dotfile. And yes you just put it at the root dir.

@djmtype
Copy link

djmtype commented Jul 11, 2021

Using this theme as is, gridsome build fails when building the site on Netlify.

I thought, inside the netlify.toml file, the WORDPRESS_URL value should be set to the exact one specified in my .env file. However, that's not the case. (I'd appreciate some explanation why this fails. BTW, I also tried adding the exact json endpoint, too. Example: https://portal.mysite.com/wp-json)

I actually, had to remove the entire [template.environment] declaration from the netlify.toml file first.

Remove:

[template.environment]
  WORDPRESS_URL = "https://portal.mysite.com"

Then in my Netlify account, goto Settings > Build & Deploy > Environment Variables, add the same credentials from my .env file.

For example:

Key = WORDPRESS_URL
Value = https://portal.mysite.com

Now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants