question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Live reload doesn't work with a custom Express setup

See original GitHub issue

What version of Remix are you using?

1.5.1

Steps to Reproduce

Create a new Remix app and configure a custom Express server as described in this example.

Run the development server and change some code. See the error in the browser console about not being able to connect to port 8002 and see no live reloading happen.

Terminate the development server and restart it, this time with an explicitly set environment variable, REMIX_DEV_SERVER_WS_PORT=8002. See no errors in the console and see live reloading happen upon code changes.

Expected Behavior

Live reloading defaults to port 8002 and works without explicitly setting the port, even for custom Express-based server setups.

Alternatively, I’d like this behaviour to be mentioned in the README of the repos that have a custom Express server because I had to figure this out by reading the source code.

Actual Behavior

Live reloading requires extra steps on every run for custom Express-based server setups.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
illrightcommented, May 28, 2022

Thanks for your input! I’d rather stick to a hardcoded port in remix.config.js for now to keep complexity out of my repo and keep it cross-platform.

 /**
  * @type {import('@remix-run/dev').AppConfig}
  */
 module.exports = {
   cacheDirectory: "./node_modules/.cache/remix",
+  devServerPort: 8002,
   ignoredRouteFiles: ["**/.*", "**/*.css", "**/*.test.{js,jsx,ts,tsx}"],
   serverBuildDirectory: "./server/build",
 };

P.S. I wish the Remix config would accept promises, then one could simply call getPort from inside the config and avoid the hassle with scripts.

1reaction
tarngerinecommented, Oct 4, 2022

For others who stumble here: in my particular setup with docker, the port 8002 wasn’t in the docker compose file as an allowed port, adding that to docker-compose.yml fixed LiveReload.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use live reload in an express server - Stack Overflow
npm install -g nodemon. next add a script line to your package.json "live": "nodemon server.js". now when you npm live it'll live reload....
Read more >
A complete guide to full-stack live reload - LogRocket Blog
In this blog post, we will examine a variety of full-stack techniques for live reload to automate the “run it” part of your...
Read more >
Why webpack-dev-server Live-Reload Is Not Working - Medium
Setting watchContentBase to true in your Webpack configuration, will 'fix' this issue, but in the wrong way.
Read more >
A simple development http server with live reload capability.
No reload on changes. Open your browser's console: there should be a message at the top stating that live reload is enabled. Note...
Read more >
Solution for Webpack 5 Dev Server Not Live Reloading
There is currently a bug with Webpack 5 and webpack-dev-server not working that is caused by the existence of a browserslist in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found