Going crazy with port & code problems - HELP!

Agent and Assistant seem to want to do things their own way. Agent keeps reverting port config to something that shows a completely different landing page than Assistant does when it restarts. I don’t understand it at all, despite hours and hours of debugging, it keeps reverting back.

Can anyone take a look at this .replit and tell me what the heck is going on?!

FWIW, “Dev” workflow is the RIGHT one, that does the right things.

modules = [“nodejs-20”, “web”, “postgresql-16”]
run = “npm run dev”
hidden = [“.config”, “.git”, “generated-icon.png”, “node_modules”, “dist”]

[nix]
channel = “stable-24_05”

[deployment]
deploymentTarget = “gce”
build = [“npm”, “run”, “build”]
run = [“sh”, “-c”, “npm run start”]

[[ports]]
localPort = 3000
externalPort = 3000

[[ports]]
localPort = 3001
externalPort = 3001

[[ports]]
localPort = 8080
externalPort = 80

[workflows]
runButton = “Dev”

[[workflows.workflow]]
name = “Project”
mode = “parallel”
author = “agent”

[[workflows.workflow.tasks]]
task = “workflow.run”
args = “Start application”

[[workflows.workflow.tasks]]
task = “workflow.run”
args = “Client”

[[workflows.workflow.tasks]]
task = “workflow.run”
args = “Server”

[[workflows.workflow]]
name = “Dev Server”
author = 36296011

[[workflows.workflow.tasks]]
task = “shell.exec”
args = “npm run dev”

[[workflows.workflow]]
name = “Dev”
author = 36296011

[[workflows.workflow.tasks]]
task = “shell.exec”
args = “PORT=3000 NODE_ENV=development tsx watch --clear-screen=false server/index.ts”

[[workflows.workflow]]
name = “Start application”
author = “agent”

[workflows.workflow.metadata]
agentRequireRestartOnSave = false

[[workflows.workflow.tasks]]
task = “shell.exec”
args = “PORT=3001 NODE_ENV=development tsx watch --clear-screen=false server/index.ts”

[[workflows.workflow]]
name = “Client”
author = “agent”

[workflows.workflow.metadata]
agentRequireRestartOnSave = false

[[workflows.workflow.tasks]]
task = “packager.installForAll”

[[workflows.workflow.tasks]]
task = “shell.exec”
args = “cd client && npm run dev”
waitForPort = 3000

[[workflows.workflow]]
name = “Server”
author = “agent”

[workflows.workflow.metadata]
agentRequireRestartOnSave = false

[[workflows.workflow.tasks]]
task = “packager.installForAll”

[[workflows.workflow.tasks]]
task = “shell.exec”
args = “PORT=3001 npm run dev”
waitForPort = 3001

I was able to fight through this with Agent/Assistant - but if I don’t explicitly tell Agent not to revert and ruin it, it will consistently revert to settings that do not work.

I suggest creating a new project with the same stack to check the default configuration.

You could also ask the Assistant or Agent to fix the .replit file, using the default configuration from the other project as a reference.

I’ve sometimes asked the Agent to remove specific workflows since workflows created by the Agent can’t be deleted from the Workflows UI, and editing the .replit file isn’t straightforward.

ChatGPT also provides good advice on this topic

I ended up using ChatGPT, but even that was a struggle.

This particular repl now requires me to explicitly say “DO NOT TOUCH NETWORK CONFIG OR OTHER UNRELATED CODE” after each prompt. If I don’t, Agent immediately tries to bork the .replit again and revert my changes. Insanity!

May not be applicable, but I found that Agent/Assistant would mess with my ports if I didn’t stop the repl when switching between them. Now I go so far as to stop my repl, go to replit home, open the repl, and then select agent or assistant.

1 Like

you can add that instruction as a comment for the agent in your server code and it’ll normally respect it

Brilliant Kody, thank you.

1 Like

Yes I causing more frustration for the user but more revenue for Replit !! But in the long run this will prove to hurt their revenue stream as it is so frustrating it drives users off the system.

Have you manually changed this? like not using the agent go into the code and manually change it.

Below is an added Configuration & Deployment category for your root-level workspace file (e.g. .replit or equivalent). Paste these into your prompt library under a new “:hammer_and_wrench: Dev & Deployment Config” section.


:hammer_and_wrench: 8. Dev Environment & Deployment Configuration

:page_facing_up:

/.replit

(or workspace root)

Section Component Prompt Debugging Prompt Optimization Prompt
modules “Explain why we’re loading nodejs-20, web, and postgresql-16 in modules. How do they interact at runtime?” “What failure modes might occur if the specified module version (e.g. PostgreSQL-16) isn’t available or mismatched? How can we surface clear errors?” “Recommend a strategy to pin or auto-update modules (e.g. use a lockfile or version ranges) to avoid drift across environments.”
run “Describe what happens when the agent executes the top-level run = ‘npm run dev’. Which processes start, and in what order?” “How would you detect if npm run dev hangs or exits with an error? Add checks or timeouts.” “Propose breaking npm run dev into explicit client/server start tasks to speed up incremental reloads during development.”
hidden “List the files/directories hidden from the workspace (.config, .git, node_modules, etc.). Why hide these?” “Could any of these hidden entries mask important logs or assets during CI/CD? How would you alert the developer?” “Suggest grouping or pattern-matching (e.g. **/node_modules) to simplify the hidden list and avoid misses as the codebase grows.”
[nix] “Explain the purpose of specifying channel = ‘stable-24_05’ under the [nix] block. What guarantees does it provide?” “What happens if the Nix channel is out of date or unavailable? How can we fallback or notify?” “Recommend pinning a specific commit or using a flake.lock to ensure reproducible Nix builds across machines.”
[deployment] “Walk through the deployment section: target gce, the build step, and the run command. How does this map to production?” “Identify any mismatches between the declared build steps (npm run build) and the actual start command (npm run start). Could they diverge?” “Propose adding a health-check or entrypoint wrapper to perform migrations or readiness probes before npm run start.”
[[ports]] “Explain each port mapping. Which service listens on 3000, 3001, and 8080? Why is external port 80 mapped to 8080?” “Check for overlapping or conflicting port definitions across workflows—what if two tasks both try to bind 3000?” “Recommend using environment variables (PORT) in workflows instead of hardcoding, to avoid stale mappings when scaling or adding new microservices.”
[workflows] “Describe the different workflows (Dev, Client, Server, Start application) and what each task does under the hood.” “What if a shell.exec task fails—does the workflow abort, retry, or continue? How can you surface failure details back to the developer?” “Suggest consolidating parallel tasks (e.g. client & server) into a single watch process or a composite command to reduce unnecessary package reinstalls.”

Usage

  1. Copy the relevant row of prompts (Component, Debugging, Optimization) into your AI agent.
  2. Replace any placeholders (if you rename ports or workflows) as needed.
  3. Run the agent, review its suggestions, and iterate by adding constraints (timeouts, retries, logging).

This ensures your LLM assistant can understand, validate, and streamline your Dev/Deploy configuration just as thoroughly as your application code.