Closed sourcesoldier closed 7 years 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
Hi, I'm experiencing the same problem as @sourcesoldier. @elementsweb, could you provide a bit more context to those settings that you added? I've made the same change and it's not helping. Does the top 15 lines of your config look like this?
#
# mozaik generic demo dashboard
#
# It's not required, but you should add this env var,
# without it, you'll probably reach the API rate limit.
#
# GITHUB_API_TOKEN=xxxxx
#
host: 0.0.0.0
port: 3000
# define duration between each dashboard rotation (ms)
rotationDuration: 10000
# define the interval used by Mozaïk Bus to call registered APIs
apisPollInterval: 100000
I think the solution to this is to run node server.js
instead of npm start
@andrewmurray your config looks good. I think the reason I set the port to be 3000 explicitly was because it was trying to proxy port 3000 to port 5000 - I couldn't see any reason for it doing this so set it to 3000 in the config.
As for for the host being set to 0.0.0.0 - this is useful if you want to preview your dashboard on another device connected to your private network.
@frankwallis I think you might be right, this rings a bell.
If you want to be able to proxy from the dev server to Mozaïk server, you can configure it through package.json.
i mean, you have not start your backend server!!!!! try start both backend and front end server concurrently
Had a similar problem and realized that I was inside the client folder rather than the parent server folder when I ran "npm start"
Spent all day fixing this, so this solution works for me:
"proxy": { "/api/*": { "target": "http://[::1]:8080" } }
If anyone else had this problem, how I solved it all the time, replace localhost to 127.0.0.1 in your package.json proxy
To avoid all this problems use nginx, super easy and will handle all this cases.
Guys, I too was getting this error message all afternoon and it was driving me crazy!
What fixed it for me was, I was running concurrently and had originally set up my scripts like this: "start": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently \"node start\" \"npm run client\""
However, once I changed it to this, the problem went away. "server": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently \"npm run server\" \"npm run client\""
Hope this helps!
My script started working when i eliminated &&
Previously it was "dev": "concurrently \"npm run client\" && \"npm run server\""
Changed it to "dev": "concurrently \"npm run client\" \"npm run server\""
I got the same issue and resolved it by changing proxy to "http://localhost:5000" instead of "https://localhost:500"
This happened to me due to an error in the server's package.json. I had copied the package.json from an older app whose "main" property referred to a different server filename than the one I was using in the new app, and so had to correct this.
Guys, I too was getting this error message all afternoon and it was driving me crazy!
What fixed it for me was, I was running concurrently and had originally set up my scripts like this: "start": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently "node start" "npm run client""
However, once I changed it to this, the problem went away. "server": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently "npm run server" "npm run client""
Hope this helps!
@gaborszekely U Mean Linux Commands?
I got the same issue and resolved it by start my backend server
I got the same issue and i resolved it by starting both backend and frontend server concurrently
first see if machine is listening on ports 3000 & 5000
sudo lsof -iTCP -sTCP:LISTEN -n -P
In my case it was not so I had to change my run command
Problem : after i say "npm start"
in vscode terminal : Proxy error: Could not proxy request /techs from localhost:3000 to http://localhost:8000/
in chrome: Cannot read property 'statusText' of undefined
} catch (err) { 21 | dispatch({ 22 | type: TECHS_ERROR,
23 | payload: err.response.statusText 24 | }); 25 | }
Solution : i used "npm run dev"
Because i was using concurrently "dev": "concurrently \"npm start\" \"npm run json-server\"",
the "techs" was in data.js file which was json data , so when you use npm start, it only starts the react-script-start "start": "react-scripts start", and it ignores data.js as our json server
That worked for me
for me, this happened because I was passing undefined value inside objectId() function. when I checked again and fixed that value >> problem solved
fala galera, para este erro, nenhuma das opções resolveram meu problema =(
I think the solution to this is to run
node server.js
instead ofnpm start
What would be server.js here? Like where would it be? what file is it and what does it do? thank you!
Hey, Please Makesure the backend server is running.
Although it is not specific to this project, I got the exact error in my react project when I was trying to proxy request from http://localhost:3000
to http://localhost:8080
.
I solved this issue by removing "proxy": "localhost:8080"
from package.json and creating a setupProxy.js file in the src folder with the following code:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:8080',
changeOrigin: true,
})
);
};
If anyone else had this problem, how I solved it all the time, replace localhost to 127.0.0.1 in your package.json proxy
Thanks a lot!
use this settings in your package.json file in react
"proxy":"http://localhost:YOUR_BACKEND_PORT" "secure":false
if the above settings not work then replace localhost with 127.0.0.1
source
I started both server and client in separate terminal First i started server using nodemon server.js Next in another tab npm start --prefix client
Everyone, make sure you also have the port number defined in your CLIENT package.json "server" property.
So go from "proxy": "http://localhost"
to "proxy": "http://localhost:5000"
Also try adding the "secure": false
parameter, seems to help some people.
(oh, and restarting your computer could help as well. It's not the first time that for some reason when I close vscode the port stays in use)
package.json/backend { "name": "backend", "version": "1.0.0", "description": "", "main": "sever.js", "type": "module",
I tried all of the solutions here and actually no one is not gonna actually solve this problem. In fact this problem is pretty random. But there is a pattern there, the 'Proxy error' always happens before the 'Server' starts. That's because the 'client' sends some request before the 'server' starts. Even if you use "dev": "concurrently "npm run server" "npm run client"" that does not guarantee the server will start before the client. The process really depends on the OS how to handle them. Unless you use a way to strictly specify the client must start after the server. That's why this error is pretty random. Actually, I think the answer of @TesheMaximillan should be the right one, some elaborations would be better.
Hey, Please Makesure the backend server is running.
i mean, you have not start your backend server!!!!! try start both backend and front end server concurrently
Save my day!!!
actually i found this issue related to the backend server is not running
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"
I think the solution to this is to run
node server.js
instead ofnpm start
I was stuck on this problem for the last 3 days and you solved it. Thank you sooo much 👍
How can i check if the backend is working well? I don't have any control of the backend. I tried almost all the solutions but none of them worked for me. I spent all the day just in this error. How frustrating it is.
Had the same problem. Realized that I used "https" instead of "http" in package.json while manually typing the proxy
Also one variant what helped me. I changed my port on server. Was "proxy": "http://localhost:7070", changed to "proxy": "http://localhost:7080"
`const express = require('express') const app = express()
app.disable('etag') app.use(require('./routes'))
app.listen(7080, () => { console.log('BALK stubs are on port 7080!') console.log('---') }) `
My problem was missing parentheses:
const router = require('express').Router;
Changing this to
const router = require('express').Router();
Guys, I too was getting this error message all afternoon and it was driving me crazy!
What fixed it for me was, I was running concurrently and had originally set up my scripts like this: "start": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently "node start" "npm run client""
However, once I changed it to this, the problem went away. "server": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently "npm run server" "npm run client""
Hope this helps!
This solution inspires me, I change my script from
"server": "nodemon server",
"client": "npm start --prefix client",
"dev": "concurrently -k \"npm:server\" \"npm:client\"",
to
"server": "nodemon server",
"client": "npm start --prefix client",
"dev": "concurrently -k \"npm run server\" \"npm run client\"",
Then the error message is gone. Maybe something wrong with concurrently
.
I was using the below configuration "server": "nodemon server", "client": "npm start --prefix client", "dev": "concurrently -k \"npm run server\" \"npm run client\"",
and did a restart. Worked for me!
Check if the issue is with the Monogo connection. I realized that my Password to connect to MongoDB got expired and updated that. Which is working fine for me now.
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
Thank you worked for me
If anyone else had this problem, how I solved it all the time, replace localhost to 127.0.0.1 in your package.json proxy
Thanks for your help. It worked for me
run the backend and frontend simultaneously
"server": "nodemon backend/server", "client": "npm start --prefix frontend", "dev": "concurrently \"npm run server\" \"npm run client\""
i mean, you have not start your backend server!!!!! try start both backend and front end server concurrently
Thank you!!!!!! Life saver! Why do i never see this simple tip anywhere?
use this settings in your package.json file in react
"proxy":"http://localhost:YOUR_BACKEND_PORT" "secure":false
if the above settings not work then replace localhost with 127.0.0.1
work for me
source
This worked for me
For anyone who uses Docker, running both back and front ends together with Docker Compose, change your
proxy
value inpackage.json
to the name of your back-end container. e.g."proxy": "http://server:8080"
. Yourdocker-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"
Works for me! Thanks!
Proxy error: Could not proxy request /signup from localhost:3000 to http://localhost:8282/. See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
I got the same issue and I just solved it by only restart both of the server, you need to run both of the server running.
Thanks me ltr:)
For anyone who uses Docker, running both back and front ends together with Docker Compose, change your
proxy
value inpackage.json
to the name of your back-end container. e.g."proxy": "http://server:8080"
. Yourdocker-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"
thank you.... this solved mine
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
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.
Current env versions:
npm -> 4.1.2 node -> 7.6.0