Ask coding questions

← Back to all posts
Problem with proxy in Express / React app
RolandJLevy

Hi,

I am trying to use a proxy so that I can run a server using express on the back-end and React using create-react-app on the front-end.

In the tutorial I am following it says I need to add this to package.json on the front-end, in the client folder: "proxy": "http://localhost:5000/" so I tried this instead, but it doesn't work: "proxy": "https://express-create-react-app.rolandjlevy.repl.co:5000/"

I get this error: Something is already running on port 5000

I'm a bit stuck and can't get it to work. Any help would be great. Thanks!

Here is the tutorial: https://www.freecodecamp.org/news/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0/

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
RolandJLevy
Comments
hotnewtop
SixBeeps

Does using just localhost:5000 not work? If not, try using 0.0.0.0:5000 instead of that URL.

RolandJLevy

@SixBeeps thanks. I tried both localhost and 0.0.0.0:5000 but got the same error: Something is already running on port 5000

RolandJLevy

Hi @SixBeeps, changing the host to 0.0.0.0 helped with setting the proxy. I left a comment explaining how I fixed the problem. Thanks :)

Korbindev

try port 5050

RolandJLevy

Hi @Korbindev, what made you think of port 5050?

RolandJLevy

I fixed the problem by going into the client folder and setting the port number in the start script in package.json. So it looks like this:

"start": "PORT=3000 react-scripts start"

Also, I changed the proxy in package.json to the following:

"proxy": "http://0.0.0.0:4080"

Here is a working version of this repl