Current Behavior
After installing the plugin, when I run 'sls offline' it is running default on port 3002. This happens even after updating the custom port in the code also with passing port in cli. If i try to access route on http://localhost:3002/hello , it returns 404.
Sample Code
service: my-service
provider:
name: aws
runtime: nodejs12.x
stage: dev
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
plugins:
- serverless-offline
custom:
# serverless offline plugin setup
serverless-offline:
httpPort: 4000
'use strict'
const { stringify } = JSON
exports.hello = async function hello() {
return {
body: stringify({ foo: 'bar' }),
statusCode: 200,
}
}
Expected behavior/code
The local server should run on port 4000 and route 'http://localhost:3002/hello' should be accessible.
Environment
serverless version: [e.g. v1.71.1]serverless-offline version: [e.g. v6.4.0]node.js version: [e.g. v10.15.3]OS: [Windows 10]Additional context/Screenshots

I have the same issue. No news?
It was actually working for older versions. New release 6.4.0 is not working in Windows and also in Ubuntu. For time being I'm using invoke local method to run function locally but it's frustrating.
My issue was a stupid indentation in the serverless.yml. Not an issue.
httpApi:
- path:
Instead of
httpApi:
- path:
My issue was a stupid indentation in the
serverless.yml. Not an issue.httpApi: - path:Instead of
httpApi: - path:
Yes, same here. I think the latest update somehow is less forgiving for these mistakes
The httpPort is the port used for your HTTP events defined in your serveless.yml.
The lambdaPort is the port used to invoke a lambda directly (also by using HTTP request, but not defined in serverless.yml).
serverless-offline make all your lambdas invokable through HTTP.
In your case, you should be able to access your endpoint at GET http://localhost:4000/hello (or POST http://localhost:3002/2015-03-31/functions/hello/invocations, which isn't what you want I assume).
_"serverless-offline": "^6.8.0",_
custom:
serverless-offline:
httpPort: 4002
tarting serverless-offline lambda server on port 3002: Error: listen EADDRINUSE: address already in use 127.0.0.1:3002
Same issue. Both setting the custom port in serverless.yml and with the cli (i.e. --httpPort 9090) does not work. It seems like a bug.
@voigtd the cli option for port is --port and it worked for me however this issue is still valid because setting the port via httpPort through serverless.yml does not work correctly
`````
custom:
serverless-offline:
lambdaPort: 4000
```````
offline: Offline [http for lambda] listening on http://localhost:4000
@dannypaz Thanks, the cli option --port is working. Odd because the serverless offline documentation says to use --httpPort for custom ports.
@Denis-String lambdaPort is not working for me, and the documentation I linked above says to use httpPort for the yml, which doesn't work either. Could be because I'm working with serverless-offline v5 and not the latest though
@voigtd thats a great catch! I didnt look at the docs, I actually used sls offline --help and saw the option. Looks like that needs to be updated
You can specify a --lambdaPort as part of the command e.g sls offline --lambdaPort 4000 this changes the default port of 3002 to 4000
sls offline --httpPort {port}
any update on this? same issue here.
serverless-offline:
httpPort: 8081
noPrependStageInUrl: true
same config and the port config stopped working on 6.8, the noPrependStageInUrl option seems to get parsed and applied
This happened to me yesterday after working at 3am. I cannot remember what I changed to make this pop up but I ended up just killing the port. Hasn't happened since 馃し
kill $(lsof -ti:PORT)
Hi, kindly do this.
sls offline --lambdaPort 4002 --httpPort 4000.
The lamda and http port can be changed to anyport you have available.
Thanks @AwesomePaul007
Indeed the httpPort works as expected, the issue is trying to use a lambdaPort that is already in use.
Voc锚 pode especificar um
--lambdaPortcomo parte do comando, por exemplo,sls offline --lambdaPort 4000isso muda a porta padr茫o de3002para4000
This command --lambdaPort 4000 solved my problem, thanks.
Most helpful comment
`````
custom:
serverless-offline:
lambdaPort: 4000
```````
offline: Offline [http for lambda] listening on http://localhost:4000
https://www.serverless.com/plugins/serverless-offline