plouc / mozaik

Mozaïk is a tool based on nodejs / react / redux / nivo / d3 to easily craft beautiful dashboards
http://mozaik.rocks
MIT License
3.61k stars 363 forks source link

Could not proxy request /config from localhost:3000 to http://localhost:5000 #118

Closed sourcesoldier closed 7 years ago

sourcesoldier commented 7 years ago

I'm trying to run the mozaik2 demo locally on my Mac with npm installed thru homebrew.

It launches the browser window but then throws an error. Please see screenshot attached.

image

Current env versions:

npm -> 4.1.2 node -> 7.6.0

ktivadar commented 2 years ago

For anyone who uses Docker, running both back and front ends together with Docker Compose, change your proxy value in package.json to the name of your back-end container. e.g. "proxy": "http://server:8080". Your docker-compose.yaml file should look similar to this:

version: "3.8"
services:
  client:
    container_name: client
    build:
      context: ./client
    ports:
      - "3000:3000"
  server:
    container_name: server
    build:
      context: ./server
    ports:
      - "8080:8080"

It worked for me! Thank you so much!

sundaysamuel250 commented 2 years ago

Proxy error: Could not proxy request /contact from localhost:3000 to http://localhost:8080/. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

above is the error from application the original port is 8080 but is showing port 3000 on my UI

ferdy-design commented 2 years ago

I'm completely new to React and working on a Mac M1 computer. I was trying to fetch data from python flask application running on the same machine on port 5000. I set "proxy": "http://127.0.0.1:5000" in package.json file, but react couldn't fetch "/profile" from the flask application.

After reading some of the answers here, it made sense that I needed to change the react host, so I ran export HOST=0.0.0.0 in the terminal.

This helped me solve the problem and now the react frontend fetches the profile data from flask successfully.

resetmerlin commented 1 year ago

Finally, I solved it. I'm using react vite, and I had a issue which is connect ECONNREFUSED 127.0.0.1:5000. This 5000 port is the server port. I was trying to fetch data from a server, and ofc I need to put the same port on the proxy.

export default defineConfig({ server: { proxy: { "/api": "http://127.0.0.1:5000", }, }, plugins: [react()], });

Even though I wrote it down correctly, it was not working ... I found out that I have to run server, and then run client. If u don't run server-side, u will get a error like me . [vite] http proxy error at /api/cyberProducts: Error: connect ECONNREFUSED 127.0.0.1:5000

++ moreover I watched this vid, and helped me a lot (https://www.youtube.com/watch?v=N4yUiQiTvwU)

kakil commented 1 year ago

I think the solution to this is to run node server.js instead of npm start

Thank you so much for this! Fixed my issue after two hours.

SuryaNarayananDev commented 5 months ago

I've experienced the same issue, I fixed it by adding this at the top of my config.yml file:

host: 0.0.0.0
port: 3000

Any idea how to fix it on react app

the port is front file working number , right ?

chouju1 commented 1 month ago

如果其他人遇到这个问题,我总是如何解决它,在 package.json 代理中将 localhost 替换为 127.0.0.1

nice兄弟,这个问题控了我好久,thank you