[Woocommerce] UNKNOWN error with credentials for local staging server

Describe the issue/error/question

I am having trouble with verification of woocommerce REST api credentials, with a wordpress server that is hosted on the same machine in another docker container. So n8n should be trying to access the site via LAN connection.

The site can be accessed normally through the browser and I have entered both keys as generated. but it still throws an error while trying to validate the credentials

I have tried with and without http:// for the url.

Is the problem related to the LAN connection?

What is the error message (if any)?

Please share the workflow

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

Share the output returned by the last node

Information on your n8n setup

  • Latest verison of N8N running in a docker container.

So I think the problem relates to woocommerce rest api requiring SSL to function properly.

I will try install SSL on the local development server and try again.

Hi @Josh-Ghazi, I gave this a go on my end. I set up the below docker compose environment including n8n, wordpress and mysql as the wordpress db:

services:
  n8n:
    image: n8nio/n8n:0.197.1
    ports:
      - 5678:5678
    volumes:
      - ./n8n:/home/node/.n8n
  
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 5679:80
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - ./wordpress:/var/www/html
  
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - ./mysql:/var/lib/mysql

I’ve then installed wordpress on http://localhost:5679 (no SSL), and installed WooCommerce through the Web UI:

Once installed, I’ve activated WooCommerce, configured it with a single product, created a WooCommerce, homepage then obtained the required credentials:

I’ve then configured my WooCommerce credentials in n8n like so (no HTTPS/SSL connection, same error as you):

Executing the node itself returns the full error message:

The error also appears in the access logs for Wordpress so the connection is at least working:

GET /wp-json/wc/v3/products?per_page=50 HTTP/1.1" 404 451 "-" "axios/0.21.4

Once I switched to “Post name” permalinks in the Wordpress settings, the error message did, however, change:

And this would indeed be the problem you suspect. As per WooCommerce REST API Documentation - WP REST API v3 you would need to use OAuth 1.0a to authenticate with Non-HTTPS/SSL WooCommerce instances. This is not currently supported by n8n’s WooCommerce node, so you’d indeed either need to set up SSL here.

1 Like

Oh my god, Thank you so much for going through all that trouble!!

That should be more than sufficient to support the SSL case , I will try to SSL the dev server. since they are on the same host machine it should work.

kindest regards
Josh

Small update, Ive managed to get SSL with self signed certificates and can access the wordpress container via HTTPS on the host machine following this guide: HERE


Using etc/hosts file and nginx i was able to access the site using a made up domain “chemex.dev”
However N8N still could not connect with API key.

Upon further investigation other machines cannot connect to Chemex.dev over the LAN, I guess its only available on the host machine. Will need to find another way to enable SSL where other machines on the network can connect over LAN.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.