Struggling to set custom PORT on remix app, you are not alone!

Its funny that remix.run (>2x) app doesn't have a direct config to set PORT.

funny ishu.dev

In DEV environment its fairly easy.

Steps:

  1. create .env file under Remix.run project 
  2. set PORT variable and assign it a value

    PORT = 4001

In PROD environment its NOT fairly easy. :D

If you are using Mac, you can pass PORT=XXXX as a flag to remix run start script.

PORT=4001 remix-serve ./build/index.js

BUT if you are using windows, it wont work :(

For windows, you have to install 

cross-env

(https://www.npmjs.com/package/cross-env)

and set the script like this

 

cross-env PORT=4001 remix-serve ./build/index.js

Well, its the only way I have found out in the Internet, and it works :)